diff --git a/packages/keystrokes/src/keystrokes.ts b/packages/keystrokes/src/keystrokes.ts index 2be325c..43b2155 100644 --- a/packages/keystrokes/src/keystrokes.ts +++ b/packages/keystrokes/src/keystrokes.ts @@ -234,6 +234,7 @@ export class Keystrokes< } checkKey(key: string) { + key = key.toLowerCase() return this._activeKeyPresses.some( (p) => p.key === key || p.aliases.has(key), ) diff --git a/packages/keystrokes/src/tests/keystrokes.spec.ts b/packages/keystrokes/src/tests/keystrokes.spec.ts index 0bb9c10..b26761e 100644 --- a/packages/keystrokes/src/tests/keystrokes.spec.ts +++ b/packages/keystrokes/src/tests/keystrokes.spec.ts @@ -591,15 +591,20 @@ describe('new Keystrokes(options)', () => { const keystrokes = createTestKeystrokes() expect(keystrokes.checkKey('a')).toBe(false) + expect(keystrokes.checkKey('ArrowRight')).toBe(false) keystrokes.press({ key: 'a' }) keystrokes.press({ key: 'a' }) + keystrokes.press({ key: 'ArrowRight' }) expect(keystrokes.checkKey('a')).toBe(true) + expect(keystrokes.checkKey('ArrowRight')).toBe(true) keystrokes.release({ key: 'a' }) + keystrokes.release({ key: 'ArrowRight' }) expect(keystrokes.checkKey('a')).toBe(false) + expect(keystrokes.checkKey('ArrowRight')).toBe(false) }) it('will return a boolean indicating if a key is pressed when using aliases', () => {