philc / vimium

The hacker's browser.
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
MIT License
23.53k stars 2.49k forks source link

Allow excluding composed keys like <space> and <escape> from sites #4284

Open philc opened 1 year ago

philc commented 1 year ago

There's many issues which touch on this, but I'll try to bring the discussion together here.

The ESC key is used in Vimium to exit insert mode, find mode, link hints, etc.

Many sites also use ESC for similar purposes. Vimium prevents the site from receiving the ESC keypress.

1985 introduced a passNextKey command, so that you can pass through a one-off escape keypress to the site.

Many issues have asked for the opposite: disable Vimium's ESC key on specific sites, and instead map the vimium escape functionality to another key.

This is not possible because we only allow single-letter keys to be excluded, and we do not support unmap <escape>.

A solution is to allow excluding and unmapping composed key strings like <escape> and <space>. This is viable, but does change the exclusions UI a bit and require a preferences data migration.

Some related issues:

gdh1995 commented 1 year ago

Um, firstly it's very easy to implement if just add unmap <escape> - we may just treat this mapping as mapKey <escape> <not_exist_key> and remove the limit of toChar.length === 1 in https://github.com/philc/vimium/blob/4c0b91fd30960a9ef47035882e81d8eabaff63c8/background_scripts/commands.js#L60-L68

Secondly, I prefer the idea to make exclusion passKeys support composed keys - a new syntax may be to separate keys with spaces, like:

j k l <space> <c-j>
shallowbit commented 7 months ago

While I was searching for a way to use: map I enterInsertMode ... but also use escape in that mode, I came across this issue.

I think these issues are related by intent but differ in execution. related issue

I'd like to be able to, temporarily, use escape by while in insert mode. Hitting escape while in this mode removes me from it. so my solution was to just temp disable vimium with a global hotkey like here but that's far from ideal because the browser settings aren't portable afak. regardless, I'd like to avoid it.

would it be better to, or is it possible to ignore/remap escape in insert mode"? This essentially makes ignoring any set of keys temporarily in insert mode a single key away.

Apologies if this is already possible.

jyn514 commented 2 months ago

it would be nice if this also allowed excluding modifier combinations per-site, like ctrl-k.

mustafa0x commented 2 months ago

I find myself needing escape to be passed through very often during browsing, especially to close modals and popovers. What do other users do? ctrl+] is a cumbersome workaround.