From 5acb4fbfde8147038c09321fbe105dc2d49de8af Mon Sep 17 00:00:00 2001 From: Ricardo Gonzalez Date: Tue, 31 Mar 2026 15:33:02 +0100 Subject: [PATCH 1/5] Add guard to normalizeKeyName() --- packages/hotkeys/src/constants.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/hotkeys/src/constants.ts b/packages/hotkeys/src/constants.ts index 5eb21911..98666b58 100644 --- a/packages/hotkeys/src/constants.ts +++ b/packages/hotkeys/src/constants.ts @@ -455,6 +455,9 @@ export function isSingleLetterKey(key: string): boolean { * ``` */ export function normalizeKeyName(key: string): string { + // key an be undefined in rare cases + // (browser extensions synthesizing key events, accessibility tools, certain OS/browser combinations). + if (!key) return '' // Check aliases first if (key in KEY_ALIASES) { return KEY_ALIASES[key]! From f04822e78ce1d5c9c8605da083d3fc0a0264f95b Mon Sep 17 00:00:00 2001 From: Ricardo Gonzalez Date: Tue, 31 Mar 2026 15:41:27 +0100 Subject: [PATCH 2/5] Add tests --- packages/hotkeys/tests/parse.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/hotkeys/tests/parse.test.ts b/packages/hotkeys/tests/parse.test.ts index c4bd2bdb..40b8c8e6 100644 --- a/packages/hotkeys/tests/parse.test.ts +++ b/packages/hotkeys/tests/parse.test.ts @@ -267,6 +267,13 @@ describe('isModifierKey', () => { }) }) +describe('normalizeKeyName', () => { + it('returns empty string for falsy input (undefined coerced, empty string)', () => { + expect(normalizeKeyName('')).toBe('') + expect(normalizeKeyName(undefined as unknown as string)).toBe('') + }) +}) + describe('rawHotkeyToParsedHotkey', () => { it('should convert minimal RawHotkey (key only)', () => { const result = rawHotkeyToParsedHotkey({ key: 'Escape' }) From b65e5894caac87408efd5a9eab5c989e8d28c2e6 Mon Sep 17 00:00:00 2001 From: Ricardo Gonzalez Date: Tue, 31 Mar 2026 16:08:50 +0100 Subject: [PATCH 3/5] Fix typo --- packages/hotkeys/src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hotkeys/src/constants.ts b/packages/hotkeys/src/constants.ts index 98666b58..f89628ed 100644 --- a/packages/hotkeys/src/constants.ts +++ b/packages/hotkeys/src/constants.ts @@ -455,7 +455,7 @@ export function isSingleLetterKey(key: string): boolean { * ``` */ export function normalizeKeyName(key: string): string { - // key an be undefined in rare cases + // key can be undefined in rare cases // (browser extensions synthesizing key events, accessibility tools, certain OS/browser combinations). if (!key) return '' // Check aliases first From e7277771f828899cb36c7a27b3d95a3bacdece82 Mon Sep 17 00:00:00 2001 From: Kevin Van Cott Date: Tue, 31 Mar 2026 12:04:50 -0500 Subject: [PATCH 4/5] add changeset --- .changeset/early-candles-warn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/early-candles-warn.md diff --git a/.changeset/early-candles-warn.md b/.changeset/early-candles-warn.md new file mode 100644 index 00000000..309bf21c --- /dev/null +++ b/.changeset/early-candles-warn.md @@ -0,0 +1,5 @@ +--- +'@tanstack/hotkeys': patch +--- + +fix: normalizeKeyName null check From 9be240b01d15709ece8386f9705f8680f5b04a70 Mon Sep 17 00:00:00 2001 From: Kevin Van Cott Date: Tue, 31 Mar 2026 12:06:34 -0500 Subject: [PATCH 5/5] regen docs --- docs/reference/variables/KEY_DISPLAY_SYMBOLS.md | 2 +- docs/reference/variables/LINUX_MODIFIER_LABELS.md | 2 +- docs/reference/variables/MAC_MODIFIER_LABELS.md | 2 +- docs/reference/variables/MAC_MODIFIER_SYMBOLS.md | 2 +- docs/reference/variables/PUNCTUATION_KEY_DISPLAY_LABELS.md | 2 +- docs/reference/variables/WINDOWS_MODIFIER_LABELS.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/reference/variables/KEY_DISPLAY_SYMBOLS.md b/docs/reference/variables/KEY_DISPLAY_SYMBOLS.md index 5812bd1c..3e7a1715 100644 --- a/docs/reference/variables/KEY_DISPLAY_SYMBOLS.md +++ b/docs/reference/variables/KEY_DISPLAY_SYMBOLS.md @@ -9,7 +9,7 @@ title: KEY_DISPLAY_SYMBOLS const KEY_DISPLAY_SYMBOLS: object; ``` -Defined in: [constants.ts:589](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L589) +Defined in: [constants.ts:592](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L592) Special key symbols for display formatting. diff --git a/docs/reference/variables/LINUX_MODIFIER_LABELS.md b/docs/reference/variables/LINUX_MODIFIER_LABELS.md index 4f5a3a04..ccd7bb39 100644 --- a/docs/reference/variables/LINUX_MODIFIER_LABELS.md +++ b/docs/reference/variables/LINUX_MODIFIER_LABELS.md @@ -9,4 +9,4 @@ title: LINUX_MODIFIER_LABELS const LINUX_MODIFIER_LABELS: Record; ``` -Defined in: [constants.ts:556](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L556) +Defined in: [constants.ts:559](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L559) diff --git a/docs/reference/variables/MAC_MODIFIER_LABELS.md b/docs/reference/variables/MAC_MODIFIER_LABELS.md index 9c07ae51..4d2dd13b 100644 --- a/docs/reference/variables/MAC_MODIFIER_LABELS.md +++ b/docs/reference/variables/MAC_MODIFIER_LABELS.md @@ -9,7 +9,7 @@ title: MAC_MODIFIER_LABELS const MAC_MODIFIER_LABELS: Record; ``` -Defined in: [constants.ts:522](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L522) +Defined in: [constants.ts:525](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L525) Modifier key labels for macOS display. diff --git a/docs/reference/variables/MAC_MODIFIER_SYMBOLS.md b/docs/reference/variables/MAC_MODIFIER_SYMBOLS.md index 33472299..66f0949f 100644 --- a/docs/reference/variables/MAC_MODIFIER_SYMBOLS.md +++ b/docs/reference/variables/MAC_MODIFIER_SYMBOLS.md @@ -9,7 +9,7 @@ title: MAC_MODIFIER_SYMBOLS const MAC_MODIFIER_SYMBOLS: Record; ``` -Defined in: [constants.ts:499](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L499) +Defined in: [constants.ts:502](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L502) Modifier key symbols for macOS display. diff --git a/docs/reference/variables/PUNCTUATION_KEY_DISPLAY_LABELS.md b/docs/reference/variables/PUNCTUATION_KEY_DISPLAY_LABELS.md index 95b19f55..5891854c 100644 --- a/docs/reference/variables/PUNCTUATION_KEY_DISPLAY_LABELS.md +++ b/docs/reference/variables/PUNCTUATION_KEY_DISPLAY_LABELS.md @@ -9,7 +9,7 @@ title: PUNCTUATION_KEY_DISPLAY_LABELS const PUNCTUATION_KEY_DISPLAY_LABELS: object; ``` -Defined in: [constants.ts:562](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L562) +Defined in: [constants.ts:565](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L565) ## Type Declaration diff --git a/docs/reference/variables/WINDOWS_MODIFIER_LABELS.md b/docs/reference/variables/WINDOWS_MODIFIER_LABELS.md index 559cef99..fb85e6c1 100644 --- a/docs/reference/variables/WINDOWS_MODIFIER_LABELS.md +++ b/docs/reference/variables/WINDOWS_MODIFIER_LABELS.md @@ -9,7 +9,7 @@ title: WINDOWS_MODIFIER_LABELS const WINDOWS_MODIFIER_LABELS: Record; ``` -Defined in: [constants.ts:545](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L545) +Defined in: [constants.ts:548](https://github.com/TanStack/hotkeys/blob/main/packages/hotkeys/src/constants.ts#L548) Modifier key labels for Windows/Linux display.