Skip to content

Instantly share code, notes, and snippets.

@frock81
Created September 24, 2024 19:05
Show Gist options
  • Save frock81/7153467b8be4d0a43d54408f6096af39 to your computer and use it in GitHub Desktop.
Save frock81/7153467b8be4d0a43d54408f6096af39 to your computer and use it in GitHub Desktop.
ChatGPT ViolentMonkey script to send with Control Enter
// ==UserScript==
// @name ChatGPT Submit with Ctrl+Enter
// @namespace Violentmonkey Scripts
// @match *://chatgpt.com/*
// @grant none
// @version 0.1
// @author -
// @description Change Enter key behavior to Ctrl+Enter for submitting
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keydown', function(event) {
if (event.key === 'Enter' && !event.ctrlKey) {
event.stopPropagation();
} else if (event.key === 'Enter' && event.ctrlKey) {
// Trigger the submit action here
const submitButton = document.querySelector('button[type="submit"]');
if (submitButton) {
submitButton.click();
}
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment