ChatGPT.com Mobile Layout Enter Key Fix

Enables Enter key submission on mobile layout

  1. // ==UserScript==
  2. // @name ChatGPT.com Mobile Layout Enter Key Fix
  3. // @namespace https://chatgpt.com
  4. // @version 1.1
  5. // @description Enables Enter key submission on mobile layout
  6. // @author MateyR
  7. // @match https://chatgpt.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. // this is forked from work by Lodimas and rbutera on https://community.openai.com/t/pressing-enter-no-longer-submits/52333
  12. (function () {
  13. 'use strict';
  14. function handleKeyPress(event) {
  15. const textarea = document.getElementById('prompt-textarea');
  16. if (textarea && event.target === textarea && event.key === 'Enter' && !event.shiftKey) {
  17. event.preventDefault();
  18. const sendbutton = document.querySelector('button[data-testid="send-button"]');
  19. if (sendbutton) {
  20. sendbutton.click();
  21. }
  22. }
  23. }
  24. document.addEventListener('keydown', handleKeyPress);
  25. })();