Commit 3c38c746 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add function to detect Ctrl+C and Ctrl+V

parent 0bb5f3a0
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -228,3 +228,17 @@ export function setAutoFocusEnabled(enabled) {
        }
    } : null
}

/**
 * Register a function that is called every time the user wants to execute Ctrl+C or Ctrl+V in the terminal.
 * Does not prevent this from being executed!
 * 
 * @param {Function} handler Function to be called without parameters on Ctrl+C and Ctrl+V
 */
export function onCopyOrPasteHotkey(handler) {
    document.querySelector("textarea.term_textarea").addEventListener("keydown", event=>{
        if(event.ctrlKey && (event.key == "c" || event.key == "v")) {
            handler()
        }
    })
}