Last active
January 12, 2025 19:54
-
-
Save ova2/24c364e3f0799ece554779d5c8f935ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ShortcutKey { | |
static readonly A = new ShortcutKey('KeyA'); | |
static readonly B = new ShortcutKey('KeyB'); | |
... | |
static readonly Digit0 = new ShortcutKey('Digit0'); | |
static readonly Digit1 = new ShortcutKey('Digit1'); | |
... | |
static readonly F1 = new ShortcutKey('F1'); | |
static readonly F2 = new ShortcutKey('F2'); | |
... | |
static readonly AltLeft = new ShortcutKey('AltLeft'); | |
static readonly AltRight = new ShortcutKey('AltRight'); | |
static readonly ShiftLeft = new ShortcutKey('ShiftLeft'); | |
static readonly ShiftRight = new ShortcutKey('ShiftRight'); | |
static readonly CtrlLeft = new ShortcutKey('ControlLeft'); | |
static readonly CtrlRight = new ShortcutKey('ControlRight'); | |
static readonly ArrowRight = new ShortcutKey('ArrowRight'); | |
static readonly ArrowUp = new ShortcutKey('ArrowUp'); | |
static readonly ArrowLeft = new ShortcutKey('ArrowLeft'); | |
static readonly ArrowDown = new ShortcutKey('ArrowDown'); | |
static readonly Delete = new ShortcutKey('Delete'); | |
static readonly Home = new ShortcutKey('Home'); | |
... | |
/** | |
* The following shortcuts are for convenience. They allow to reduce registering | |
* shortcuts for left and right keys on keyboard. For instance, instead of registering | |
* [AltLeft, another key, ...] + [AltRight, another key, ...], you can write | |
* [Alt, another key, ...], regardless which Alt key was pushed. | |
*/ | |
static readonly Alt = new ShortcutKey(['AltLeft', 'AltRight']); | |
static readonly Ctrl = new ShortcutKey(['ControlLeft', 'ControlRight']); | |
static readonly Shift = new ShortcutKey(['ShiftLeft', 'ShiftRight']); | |
static readonly Meta = new ShortcutKey(['MetaLeft', 'MetaRight']); | |
// private to disallow creating other instances of this type | |
private constructor(public readonly keyCode: string | string[]) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment