Google AI Studio - Send on Enter (Simulates Ctrl+Enter)

Press Enter instead of Ctrl+Enter to send prompts in Google AI Studio.

  1. // ==UserScript==
  2. // @name Google AI Studio - Send on Enter (Simulates Ctrl+Enter)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3.1
  5. // @description Press Enter instead of Ctrl+Enter to send prompts in Google AI Studio.
  6. // @author AI
  7. // @match https://aistudio.google.com/*
  8. // @grant none
  9. // @license MIT
  10. // @run-at document-idle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. document.addEventListener('keydown', function(event) {
  17. const activeElement = document.activeElement;
  18.  
  19. if (event.key === 'Enter' && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
  20.  
  21. if (activeElement && activeElement.tagName === 'TEXTAREA') {
  22. event.preventDefault();
  23. event.stopPropagation();
  24.  
  25. const ctrlEnterEvent = new KeyboardEvent('keydown', {
  26. key: 'Enter',
  27. code: 'Enter',
  28. bubbles: true,
  29. cancelable: true,
  30. ctrlKey: true
  31. });
  32.  
  33. activeElement.dispatchEvent(ctrlEnterEvent);
  34. }
  35. }
  36. }, true);
  37.  
  38. })();