Skip to content

Commit

Permalink
Vomnibar: fix a bug preventing ctrl-enter from working
Browse files Browse the repository at this point in the history
Chrome may assign `"\n"` as the `key` property of an `Enter` key,
which made `Ctrl+Enter` not work as expected.
  • Loading branch information
gdh1995 authored and philc committed May 22, 2022
1 parent e10d269 commit 7a9fc8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/keyboard_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Utils.monitorChromeStorage("mapKeyRegistry", (value) => { return mapKeyRegistry
const KeyboardUtils = {
// This maps event.key key names to Vimium key names.
keyNames: {
"ArrowLeft": "left", "ArrowUp": "up", "ArrowRight": "right", "ArrowDown": "down", " ": "space"
"ArrowLeft": "left", "ArrowUp": "up", "ArrowRight": "right", "ArrowDown": "down", " ": "space",
"\n": "enter" // on a keypress event of Ctrl+Enter, tested on Chrome 92 and Windows 10
},

init() {
Expand Down
2 changes: 1 addition & 1 deletion pages/vomnibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class VomnibarUI {
} else if ((key === "down") ||
(event.ctrlKey && ((key === "j") || (key === "n")))) {
return "down";
} else if (event.ctrlKey && (event.key === "Enter")) {
} else if (event.ctrlKey && (key === "enter")) {
return "ctrl-enter";
} else if (event.key === "Enter") {
return "enter";
Expand Down

0 comments on commit 7a9fc8d

Please sign in to comment.