Listen for some hotkeys on form fields #85
Answered
by
keithamus
SethHorsley
asked this question in
Q&A
-
How doees github listen for all command palette hotkeys |
Beta Was this translation helpful? Give feedback.
Answered by
keithamus
Mar 6, 2023
Replies: 1 comment
-
In cases where we need a global shortcut that will work in all inputs, we use manual event listeners. The code might look a bit like: import {eventToHotkeyString} from '@github/hotkey'
const GLOBAL_HOTKEY = 'Cmd+K'
document.addEventListener('keydown', (event) => {
let hotkeyString = eventToHotkeyString(event)
if (!hotkeyString) return
if (hotkeyString !== GLOBAL_HOTKEY) return
runGlobalHotkeyCommand()
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
keithamus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In cases where we need a global shortcut that will work in all inputs, we use manual event listeners. The code might look a bit like: