Created
November 1, 2024 19:53
-
-
Save Strajk/4fbede6a11767de8f820f574db48dadd to your computer and use it in GitHub Desktop.
Userscript to Restore cmd+k shortcut for new chat, new history search is now cmd+shift+k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name ChatGPT: Restore cmd+k shortcut for new chat | |
| // @description Restore cmd+k shortcut for new chat, new history search is now cmd+shift+k | |
| // @version 0.1 | |
| // @author strajk <[email protected]> (https://github.com/Strajk) | |
| // @match https://chatgpt.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| // ChatGPT recently changed keyboard shortcut to open new chat | |
| // from cmd + K to cmd + shift + O | |
| // let's remap it back! And allow the new cmd + K work with Shift | |
| document.addEventListener("keydown", (event) => { | |
| if (event.metaKey && event.key === "k" && !event.shiftKey) { | |
| console.log("CMD+K caught, cancelling default and triggering CMD+SHIFT+O") | |
| // Stop the default behavior... | |
| event.preventDefault() | |
| event.stopPropagation() | |
| // ...and trigger "cmd +shift + o" instead | |
| document.dispatchEvent(new KeyboardEvent("keydown", { | |
| key: "o", | |
| shiftKey: true, | |
| metaKey: true, | |
| })) | |
| } | |
| }, { capture: true }) | |
| }()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment