solid-primitives
solid-primitives copied to clipboard
createShortcut but allow any permutation
Describe The Problem To Be Solved
This may not be a bug, and if not I think it would be a nice thing to add as another function or option.
I want to use createShortcut(["Shift", "Control", "M"], () => {})
and have it trigger the function on any permutation of key presses, so how vscode does it with their shortcuts.
Suggest A Solution
I have a rough implementation of it using useKeyDownList
, so something like this but maybe with also a length check?
const keys = useKeyDownList();
const myShortcut = new Set(["SHIFT", "CONTROL", "M"]);
createEffect(() => {
const keyList = keys();
for (const key of keyList) {
if (!myShortcut.has(key)) return;
}
someCallback();
});