mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
15 lines
474 B
TypeScript
15 lines
474 B
TypeScript
export function eventToKeybind(e: KeyboardEvent): string {
|
|
if (["Control", "Alt", "Shift", "Meta"].includes(e.key)) return "";
|
|
const parts: string[] = [];
|
|
if (e.ctrlKey) parts.push("ctrl");
|
|
if (e.altKey) parts.push("alt");
|
|
if (e.shiftKey) parts.push("shift");
|
|
if (e.metaKey) parts.push("meta");
|
|
parts.push(e.key);
|
|
return parts.join("+");
|
|
}
|
|
|
|
export function matchesKeybind(e: KeyboardEvent, bind: string): boolean {
|
|
return eventToKeybind(e) === bind;
|
|
}
|