mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-10-21 19:25:22 +00:00
🐛 Guard event.key before toLowerCase in search keydown handler
The global keydown handler calls event.key.toLowerCase() without checking that event.key is defined. Some keydown events carry no key property (browser autofill, IME composition, some mobile virtual keyboards), which throws TypeError: Cannot read properties of undefined (reading 'toLowerCase') and breaks the handler for that keystroke. Add a truthiness guard before calling toLowerCase(), matching the style already used for the other event.key comparisons in the same handler. No behavior change for real Cmd/Ctrl+K presses.
This commit is contained in:
1 parent
efe0bcf9a8
commit
2e7c5bb91f
1 file changed
+1
-1
+1
-1
@@ -42,7 +42,7 @@ document.addEventListener("keydown", function (event) {
|
||||
}
|
||||
|
||||
// Cmd+K (macOS) / Ctrl+K to toggle search wrapper
|
||||
if (event.key.toLowerCase() == "k" && (event.metaKey || event.ctrlKey)) {
|
||||
if (event.key && event.key.toLowerCase() == "k" && (event.metaKey || event.ctrlKey)) {
|
||||
event.preventDefault();
|
||||
if (searchVisible) {
|
||||
hideSearch();
|
||||
|
||||
Reference in new issue
Block a user