Hotkeys: Ctrl or Cmd + Enter

Add an utility to easily create the callback binding to an enter + ctrl or cmd in a component
This commit is contained in:
estib 2024-09-30 10:04:58 +02:00
parent 29b37f5cab
commit 215af9fc79

View File

@ -43,3 +43,11 @@ export function createKeybind(keybinds: KeybindDefinitions) {
return createKeybindingsHandler(keys); return createKeybindingsHandler(keys);
} }
export function onMetaEnter(callback: () => void) {
return (e: KeyboardEvent) => {
if (e.key === KeyName.Enter && (e.metaKey || e.ctrlKey)) {
callback();
}
};
}