philc / vimium

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

[[ or ]] are activating insert mode (V1.49) #1529

Open marcelpaulo opened 9 years ago

marcelpaulo commented 9 years ago

[[ and ]] are activating insert mode:

mamdouh el gbaly - google search - google chrome_001

I tried mapping goNext to gn, for instance, and it doesn't activate insert mode.

vimium options - google chrome_003

mrmr1993 commented 9 years ago

My gut instinct is that we're not detecting the keydown event as [ because of the keyboard layout, and so google is catching it and focusing their input with it instead. Which keyboard layout are you using?

marcelpaulo commented 9 years ago

I'm using Portuguese (Brazil):

keyboard_004

You nailed it ! Just to confirm, I tested this:

  1. Changed the layout to English (US) and checked which key was generated when pressing ]: it was \
  2. Changed the keyboard back to Portuguese (Brazil)
  3. Mapped goNext to \\
  4. Pressed ]] on the Google page, and the goNext action was run
smblott-github commented 9 years ago

@marcelpaulo: Could you go here, click in the bottom right frame, and let us know what keyboard events are generated (if any) when you type ]?

marcelpaulo commented 9 years ago

Here they are @smblott-github:

jquery key events test console - jsfiddle - google chrome_001

smblott-github commented 9 years ago

Sorry, @marcelpaulo. Was ]] mapped on the options page for that?

Edit: I'm guessing this has something to do with the logic here.

marcelpaulo commented 9 years ago

Here's the mapping on the options page, @smblott-github:

vimium options - google chrome_002

smblott-github commented 9 years ago

Thanks, @marcelpaulo. It does indeed look like it's this logic which is at fault. Changing my own keyboard layout to Portuguese, I get the same keydown, keyup events, with no keypress. Hmm, not what can be done...

mrmr1993 commented 9 years ago

When this Chromium issue is resolved, we can stop using keypress altogether, reliably get the key from keydown and all this pain will go away.

Until then, we could hook up some mechanism that 'learns' which keydowns corollate with which keypresses as the user types in textboxes, but that's kinda clunky and unreliable. And it's hard to deal with users that regularly switch locales. I don't really like this idea, but it would fix things for some users.