Closed rin-yato closed 1 year ago
Thanks for suggestion. The Command/Ctrl + Enter
has bee suggested before. Maybe the best is to let people bind their own key? We can extend this functionality. If you want to extend this, I can provide some guideline how to achieve it.
You may provide the guideline, I will help out with what I can.
Got it. Let me do some design to give you some idea how to achieve it
We can start by doing the following
const [keybinding] = useState(() => ({
'RUN': { mac: 'Command+Enter', win: 'Ctrl+Enter' },
'RUN_SELECTION': { mac: 'Command+Shift+Enter', win: 'Ctrl+Shift+Enter' }
}))
const getKeybinding = useCallback((key: string) => {
return keybinding[key];
}, [keybinding])
const matchKeybinding = useCallback((e: EventKeySomething, key: string) => {
// returning true if the key event is matched
}, [keybinding])
<KeybindingProvider value={{getKeybinding }}>
{ /*... */}
</KeybindingProvider>
I believe other place can do as following:
const {getKeybinding, matchKeybinding} = useKeybinding();
const onKeypress = useCallback(e => {
if (matchKeybinding(e, 'RUN')) {
// do something
}
}, [getKeybinding])
I think F9 isnt the best hotkey to execute sql. Since many people use keyboard that cant easily type the F9 key. Maybe
command/ctrl + enter
is a good hotkey?