diff --git a/content_scripts/commands.js b/content_scripts/commands.js index 96f8f6f..7122ccd 100644 --- a/content_scripts/commands.js +++ b/content_scripts/commands.js @@ -92,6 +92,10 @@ Commands = { "j": "moveDown", "h": "moveLeft", "l": "moveRight", + "up": "moveUp", + "down": "moveDown", + "left": "moveLeft", + "right": "moveRight", // Row & column movement "": "moveRowsDown", diff --git a/content_scripts/ui.js b/content_scripts/ui.js index f990756..4d2b6e0 100644 --- a/content_scripts/ui.js +++ b/content_scripts/ui.js @@ -231,8 +231,21 @@ UI = { this.keyQueue = []; this.cancelEvent(e); Commands.commands[commandName].fn(); + return; } } + + // Cancel the event if the mode matches "normal" or "visual*", + // to prevent accidentally input an unassigned character like "w" or "b". + // Ensure that the key is not pressed with ctrl or meta, + // not to mask Google Sheets' default shortcuts such as ⌘-F. + if ( + !e.ctrlKey && + !e.metaKey && + ["normal", "visual", "visualLine", "visualColumn"].includes(this.mode) + ) { + this.cancelEvent(e); + } }, // modifiers: optiona; an object with these boolean properties: meta, shift, control.