philc / vimium

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

Ignore keyboard layout doesn't work with non-standard English layout #2834

Open Forever-Young opened 6 years ago

Forever-Young commented 6 years ago

For example I have English (Colemak) and Russian (standard)

In VimFx I used this settings:

vimfx.set('translations', {
  // Colemak mappings.
    "KeyE": ["f", "F"],
    "KeyR": ["p", "P"],
    "KeyT": ["g", "G"],
    "KeyY": ["j", "J"],
    "KeyU": ["l", "L"],
    "KeyI": ["u", "U"],
    "KeyO": ["y", "Y"],
    "KeyP": [";", ":"],
    "KeyS": ["r", "R"],
    "KeyD": ["s", "S"],
    "KeyF": ["t", "T"],
    "KeyG": ["d", "D"],
    "KeyJ": ["n", "N"],
    "KeyK": ["e", "E"],
    "KeyL": ["i", "I"],
    "Semicolon": ["o", "O"],
    "KeyN": ["k", "K"],

    "CapsLock":    "Backspace"
});
smblott-github commented 6 years ago

Vimium normally uses event.key for key handling. If the Ignore keyboard layout is selected, then Vimium mainly uses event.code. You can test what values are generated for your set up here.

There are various special cases; the logic is here.

Perhaps you can figure out what's going on.

Forever-Young commented 6 years ago

Right after I enable Ignore, it works as if I would have qwerty layout (even if English is selected)

lydell commented 6 years ago

To clarify, this is not a bug, but a feature request for VimFx's translations option. I had no idea anybody actually used that option! Glad to hear it was useful to you.

"Ignore keyboard layout" in Vimium works as intended: It ignores the layout you've chosen in your OS. That includes Colemak. Instead, en-US QWERTY is used (since it is the most common).

Lots of users use en-US QWERTY plus one other layout (such as Russian). Then "Ignore keyboard layout" is great – you can use Vimium the same way regardless of which layout you happen to have activated at the moment with no further config required.

But what if you use some other layout combo, such as Colemak plus Russian? (That's the problem @Forever-Young has.) Or Swedish plus Greek?

One way is of cource to change every single Vimium shortcut. For example, changing f to e for Colemak. The downside is that this ruins the help dialog.

That's why VimFx had the translations option. Using @Forever-Young's config above would result in Colemak instead of QWERTY when using "Ignore keyboard layout".

You can read all about the translations option here:

smblott-github commented 6 years ago

Thanks for the background, @lydell.

In that case, perhaps this is what is needed.

lydell commented 6 years ago

@smblott-github Ah, that looks promising. I guess people would want it in Hints mode as well, though. @Forever-Young Try it out and see what you think!

Forever-Young commented 6 years ago

@lydell Yeah, for some keys that works fine, just because of their placement (J, K up and down, in Colemak they are N and E), so I need to completely remap them. But for the main (especially not often used) part, that would mean some copy-pasting.

Made a 'map'-ish default settings:

# default part
unmapAll
map ? showHelp
map j scrollDown
map k scrollUp
map h scrollLeft
map l scrollRight
map gg scrollToTop
map G scrollToBottom
map zH scrollToLeft
map zL scrollToRight
map <c-e> scrollDown
map <c-y> scrollUp
map d scrollPageDown
map u scrollPageUp
map r reload
map gs toggleViewSource
map i enterInsertMode
map v enterVisualMode
map V enterVisualLineMode
map H goBack
map L goForward
map gu goUp
map gU goToRoot
map gi focusInput
map f LinkHints.activateMode
map F LinkHints.activateModeToOpenInNewTab
map <a-f> LinkHints.activateModeWithQueue
map yf LinkHints.activateModeToCopyLinkUrl
map / enterFindMode
map n performFind
map N performBackwardsFind
map [[ goPrevious
map ]] goNext
map yy copyCurrentUrl
map p openCopiedUrlInCurrentTab
map P openCopiedUrlInNewTab
map K nextTab
map J previousTab
map gt nextTab
map gT previousTab
map ^ visitPreviousTab
map << moveTabLeft
map >> moveTabRight
map g0 firstTab
map g$ lastTab
map W moveTabToNewWindow
map t createTab
map yt duplicateTab
map x removeTab
map X restoreTab
map <a-p> togglePinTab
map <a-m> toggleMuteTab
map o Vomnibar.activate
map O Vomnibar.activateInNewTab
map T Vomnibar.activateTabSelection
map b Vomnibar.activateBookmarks
map B Vomnibar.activateBookmarksInNewTab
map ge Vomnibar.activateEditUrl
map gE Vomnibar.activateEditUrlInNewTab
map gf nextFrame
map gF mainFrame
map m Marks.activateCreateMode
map ` Marks.activateGotoMode
smblott-github commented 6 years ago

@lydell ... are you thinking something like this... 988fd8adabdb15193b66fe63c0601ef85faf157a (use mapkey also for link hints and marks)?

Could that have unintended side effects?

lydell commented 6 years ago

Yes, that looks like what I was thinking. In VimFx, the translations option is used for all keyboard handling, no matter where or what mode.

However, I don't know very much about mapkey. It seems to be basically the same thing as translations in VimFx. But perhaps there's some subtle difference I do not know about? I guess it helps reviewing the issues and PR about it. For example, what was the reason not to use it for Hints mode initially?

Also, @Forever-Young, did you try mapkey?

nisnevich commented 2 years ago

I also have US Colemak + RU Standard setup, and these mappings work good to me. It includes a solution of https://github.com/philc/vimium/issues/3248 for both layouts.

" Some basic Colemak mappings mapkey n j mapkey N J mapkey e k mapkey E K mapkey i l mapkey I L mapkey k n mapkey K N map s InsertMode map gh visitPreviousTab map l Vomnibar.activateEditUrl " Lowercase RU mappings mapkey й q mapkey ц w mapkey у f mapkey к p mapkey е g mapkey н j mapkey г l mapkey ш u mapkey щ y mapkey з ; mapkey х [ mapkey ъ ] mapkey ф a mapkey ы r mapkey в s mapkey а t mapkey п d mapkey р h mapkey о j mapkey л k mapkey д l mapkey ж o mapkey э ' mapkey я z mapkey ч x mapkey с c mapkey м v mapkey и b mapkey т n mapkey ь m mapkey б , mapkey ю . mapkey . / " Capital RU mappings mapkey Й Q mapkey Ц W mapkey У F mapkey К P mapkey Е G mapkey Н J mapkey Г L mapkey Ш U mapkey Щ Y mapkey З : mapkey Х { mapkey Ъ } mapkey Ф A mapkey Ы R mapkey В S mapkey А T mapkey П D mapkey Р H mapkey О J mapkey Л K mapkey Д L mapkey Ж O mapkey Э " mapkey Я Z mapkey Ч X mapkey С C mapkey М V mapkey И B mapkey Т N mapkey Ь M mapkey Б < mapkey Ю > mapkey , ?