Skip to content

Instantly share code, notes, and snippets.

@bulletinmybeard
Last active January 4, 2024 05:58
Show Gist options
  • Save bulletinmybeard/1c2b8a3858f4485a9ff146f06c85ab56 to your computer and use it in GitHub Desktop.
Save bulletinmybeard/1c2b8a3858f4485a9ff146f06c85ab56 to your computer and use it in GitHub Desktop.
ChatGPT (chat.openai.com) - Disable keyboard command `CMD+K` that clears the prompt form and resets the URL (macOS!)
// ==UserScript==
// @name ChatGPT (chat.openai.com) - Disable keyboard command `CMD+K`
// @namespace https://rschu.me/
// @homepage https://rschu.me/
// @version 1.0.0
// @encoding utf-8
// @description ChatGPT (chat.openai.com) - Disable keyboard command `CMD+K` that clears the prompt form and resets the URL
// @author Robin Schulz
// @match *://chat.openai.com/c/*
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible safari
// @connect chat.openai.com.com
// @run-at document-end
// ==/UserScript==
(async () => {
/**
* Event listener for the 'keydown' event.
* If the Meta (Command on macOS) key and 'K' key are pressed together,
* this function prevents the default action and stops the event from propagating.
*
* @param {KeyboardEvent} event - The keyboard event object.
*/
document.addEventListener('keydown', (event) => {
if (event.metaKey && event.keyCode === 75) {
event.preventDefault()
event.stopImmediatePropagation()
}
})
})().catch(err => {
console.error(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment