Skip to content

Trigger commands in an input box

Dahan Gong edited this page Nov 22, 2021 · 11 revisions

If a user wants to keep Vimium C's commands usable even when an input box is focused, here's some advices:

Trigger commands of Vimium C

  • press Esc or Ctrl+[ to "blur" input boxes and then Vimium C will go back to normal mode and consume following keys
    • <esc> and <c-[> can be mapped. For example, mapkey <c-]> <esc> will make Ctrl+] (during Vimium C consumes it) work like Esc
    • there's a command named switchFocus, and you may use it to re-focus the most-recently-focused input box, when you have pressed Esc
  • map some keys which contains F1 ~ F12
    • Vimium C will keep such keys, whose main key is F1~F12, usable even in a default insert mode
      • of course not in the insert mode entered by the command enterInsertMode
    • For example, map <s-f8> LinkHints.activate makes Shift+F8 always trigger LinkHints mode
    • But map <f8>f LinkHints.activate can not be triggered in a default insert mode, because the second key, f, is not in F1~F12
      • if press <f8> and then f, then <f8> will be consumed by Vimium C, and f will be passed through to a input box itself.
  • configure global shortcuts on chrome://extensions/shortcuts or about:addons (Firefox)
    • command shortcuts configured here are always usable, unless some of browser's built-in shortcuts have higher priorities.
    • if the command you want is not in the list, you may setup "User Customized" 1 and 2, and add something like shortcut userCustomized1 command="goBack" into "Custom key mappings" on Vimium C Options page
    • if the 2 placeholders are not enough, there's an assistant extension named Shortcut Forwarding Tool to let you setup more.
    • on Firefox, please visit about:addons manually, click the settings icon button and click Manage Extension Shortcuts
  • long keys ending with :i also work in a plain insert mode, since v1.84.1
    • for example, map <c-j:i> editText run="auto,forward,line" will move caret down by a line, only in insert mode
    • but they do not work in any global insert mode of enterInsertMode
  • long keys starting with v- always work in a plain insert mode, since v1.92.0

On <esc> not blur but trigger a page's Escape

Here's an example to simulate a pair of Escape keyboard events to trigger actions of a page itself and other extensions:

mapKey <c-]> <v-esc_pair>
map <v-esc_pair> runKey keys="+esc-esc"
map <v-esc> dispatchEvent type="keydown" code="Escape" key="Escape" keyCode=27

This method requires the command dispatchEvent, which is available since v1.92.4 .

Clone this wiki locally