vimium icon indicating copy to clipboard operation
vimium copied to clipboard

Escape key doesn't work (firefox)

Open j-cr opened this issue 3 years ago • 15 comments

The extension doesn't react to the escape key in any context, thus making it impossible to exit to normal mode or to cancel an action.

  • press f, then press escape
  • expected: hints are removed, the page goes back to normal mode
  • actual: nothing happens, the page stays in the link selection mode

Same with visual selection, vomnibar, etc; escape key doesn't work in any context.

Note that the browser only receives the key UP event for the escape key, not the key down event. I wonder if that has something to do with it. I've tested it in tridactyl too, same behavior. Any ideas?

Mozilla Firefox 68.9.0esr Vimium 1.66

j-cr avatar Oct 26 '20 07:10 j-cr

Works as inteded with a fresh profile. The problem is profile-specific. Still keeping it open in case someone encountered a similar problem.

j-cr avatar Oct 26 '20 07:10 j-cr

Could you do a simple test to find what Vimium got?

  • open https://gdh1995.cn/vimium-c/keyboard-test.html
  • click Vimium's icon and save options to make Vimium disabled on the page
  • reload the page, and enable "disable Vimium / Vimium C / VimFx"
  • then press Escape to see what it will log.

gdh1995 avatar Oct 26 '20 07:10 gdh1995

@gdh1995 keyup only for escape, whether the extension is disabled or not. It makes no difference if it's enabled or disabled in regards to the escape key events.

As a side note, I noticed sometimes I get key up events from normal navigation keys (j, k, etc) too when I press them in a quick succession. Unrelated, but curious maybe.

j-cr avatar Oct 26 '20 07:10 j-cr

Then this is an issue of Firefox itself, or does another extension hook the keydown events?

gdh1995 avatar Oct 26 '20 07:10 gdh1995

I've only been able to reproduce the issue with firefox and with a single specific profile that I use. In this profile, neither vimium nor tridactyl receive the escape key. On a fresh profile however both extensions work fine.

Of course, I've tried disabling every other extension except for vimium, but that doesn't affect the issue; so I can't pinpoint the cause, and I'm not sure what else I can try to find the cause. Some kind of about:config switch that affects escape key behavior?.. I'm running out of ideas.

Is it possible to remap (via config) at least some of the "unfocus"/"return to normal mode" commands to another key? E.g. make it so pressing space exits the link selection mode? Or make C-[ do the same, as it does in vim?

EDIT: seems like the answer is no, it's all hardcoded (via isEscape), e.g.: https://github.com/philc/vimium/blob/4c45726c0c05eb5381ab58d9ce629972e801eb43/content_scripts/mode_find.js#L58

j-cr avatar Oct 26 '20 07:10 j-cr

You may use <c-[>, and it works like <esc> at most places (when no map <c-[> someCommand).

And KeyboardUtils.isEscape supports mapkey <anykey> <c-[> in key mappings.

gdh1995 avatar Oct 26 '20 08:10 gdh1995

Oh, C-[ is supposed to work out of the box? It doesn't work for me. On https://gdh1995.cn/vimium-c/keyboard-test.html I see that the key down events gets "eaten" by vimium when it's enabled, but it produces absolutely no effect.

The mapkey trick however works! mapkey <c-g> <c-[> makes C-g work like escape in all relevant contexts. I find it to be quite weird, since C-[ itself doesn't work at all. Any ideas about what's happening?

Also, I noticed that as a workaround I can use backspace in link selection mode and find mode (but not in vomnibar).

j-cr avatar Oct 26 '20 08:10 j-cr

What will the test page log for Ctrl+[ on your Firefox when Vimium is disabled?

gdh1995 avatar Oct 26 '20 08:10 gdh1995

keydown control keyup [ keyup control

...well, which is exactly the same as when it's enabled :/ Same happens for C-], but for C-S-[ (aka C-{) or C-' or ctrl + any alphanumerics the behavior is normal (both key down and key up events are displayed for both ctrl and the second key). I'm quite confused, it seems like firefox specifically treats escape, ctrl+[ and ctrl+] in a weird way.

EDIT: alt+[ and shift+[ also work as intended; so far I'm unable to find any keys or combinations that behave weirdly beside these 3

j-cr avatar Oct 26 '20 08:10 j-cr

Just noticed this is happening to me when trying to escape from github's finder feature. Vimium is eating the esc somehow: the problem resolves when using a blank rule to disable Vimium. Keycodes are as expected for esc and C-[

trysten avatar Dec 27 '20 13:12 trysten

I have the exact same issue. The keydown event for the Escape key isn't being registered on e.g https://w3c.github.io/uievents/tools/key-event-viewer.html. Troubleshoot mode (safe mode = all extensions disabled) doesn't fix it, but creating a new profile does. I also suspected something in about:config, but nothing stood out. Very strange!

arisolt avatar Sep 18 '23 21:09 arisolt

Had the issue that 'esc' was not working and only 'c-esc' exited modes as expected. Problem was solved for me after resetting "permissions.default.shortcuts" in about:config, which I have seem to changed a while back :) Maybe this helps someone in the future...

FriederRodewald avatar Feb 08 '24 10:02 FriederRodewald

Had the issue that 'esc' was not working and only 'c-esc' exited modes as expected. Problem was solved for me after resetting "permissions.default.shortcuts" in about:config, which I have seem to changed a while back :) Maybe this helps someone in the future...

This fixed it for me too! Thank you!

Unfortunately this was a very useful setting, because it prevented websites like Twitter and Github from hijacking keys. But it shouldn't have interferred with the Esc keypress events. It could be a bug in Firefox.

arisolt avatar Feb 08 '24 11:02 arisolt

During my tests on Firefox 122, Win11, keydown#key=Escape will be blocked by permissions.default.shortcuts=2, while Ctrl+[ and Ctrl+] works as intended.

gdh1995 avatar Feb 13 '24 09:02 gdh1995

@gdh1995 is absolutely right. I had the same issue for a long time, and this is exactly what the problem was: permissions.default.shortcuts set to 2 is about:config (which means to block websites from overriding keys by default).

And for reference, it doesn't just block the Escape key for Vimium, but for ALL Firefox extensions (i.e Ublock Origin's zapper/picker for instance).

We need to contact Mozilla about this as this is a huge issue for keyboard-centric users on Firefox.

adamency avatar Jun 17 '24 15:06 adamency