Open SirVer opened 8 years ago
I knew Neo2 keyboard layout at first time... Looks nice!
Could you tell me how you input special keys such as ~
, :
, ?
? From your link, the keyboard layout seems to have some states and such special keys can be input on one of them.
I guess they require some modifier key.
NyaoVim currently handles inputs which include modifier key (e.g. <C-l>
) via keydown
event and other non-modifier inputs (e.g. a
, A
, and so on) via input
event of <input>
element. (source code)
Let me explain with :
input for example.
In normal keyboard, :
requires shift + ;
input. It is not caught on keydown
event because no modifier key (ctrl, alt) is pushed. Then the input :
is caught on input
event and NyaoVim sends sequence :
to Neovim process.
But if your keyboard includes modifier key on inputting :
, NyaoVim wrongly catches it on keydown
event.
I think it is very helpful to show me the KeyboardEvent
instance on keydown
event when you input :
on Chrome (or Chromium).
Could you tell me how you input special keys such as ~, :, ??
Sure, for example ? is inputted by holding CAPSLOCK + h or # + h (on an qwertz keyboard). Capslock or # function as an additional modifier keys, similar to LSHIFT and RSHIFT but enabling another layer (not capital letters, but special symbols). There is one more set of modifier keys: < and RIGHT_CMD enable numlock and cursor keys.
I think it is very helpful to show me the KeyboardEvent instance on keydown event when you input : on Chrome (or Chromium).
I am a backend developer, I am not familiar with debugging inside chrome. If you tell me how to get this data, I will provide it.
Thank you for description.
Sure, for example ? is inputted by holding CAPSLOCK + h or # + h (on an qwertz keyboard). Capslock or # function as an additional modifier keys, similar to LSHIFT and RSHIFT but enabling another layer (not capital letters, but special symbols). There is one more set of modifier keys: < and RIGHT_CMD enable numlock and cursor keys.
Hmm... CAPSLOCK and other keys used as modifier may cause this issue. I want to know what they send to browser.
I am a backend developer, I am not familiar with debugging inside chrome. If you tell me how to get this data, I will provide it.
OK, let me explain.
index.html
<body>
<body>
<script>
window.addEventListener('keydown', function (e) { console.log(e); });
</script>
python -m SimpleHTTPServer 1234
http://localhost:1234
in Chrome and DevTools (Cmd + option + i
or from tool bar menu).I inserted ? which is Mod3 + h
. I did it once with the left Mod3 which is CAPSLOCK and once with the right mod3 which is #. Note that under Mac OS X Mod3 == ALT.
Left one: it send two events, once for pressing (and holding CAPSLOCK) and one for the h key:
CAPSLOCK:
then H:
Now the right side, first pressing #:
and pressing h:
Sorry for late response and thank you very much for these screenshots. They're very helpful.
It seems that your keyboard sends altKey: true
on those keys. <neovim-editor>
recognizes it as you sent modifier key.
For example, H
sends altKey: true
and key code 191
(char: "¿"
) hence <neovim-editor>
recognizes it as <A-¿>
.
This problem currently can't be solved because we can't know which keyboard is used.
However, there may still be possibility to fix this problem. As new member of KeyboardEvent
, code
will be added. (MDN document) If code
is added, we can use it in stead of key code and no longer need to convert key code. It means that hopefully any input can be caught in spite of keyboard layouts.
Unfortunately KeyboardEvent.code
is not implemented to Chromium 47 (latest Electron) yet, but Chrome 48 beta already seemed to implement it. After Electron introducing Chromium 48, we can try KeyboardEvent.code
.
So I'll open this issue for that.
sounds promising. Thank you.
maybe this helps you narrow down the issue: I am using Neo2 as well and just tried NyaoVim. I have not experienced any of the aforementioned problems using NyaoVim's AUR package for Arch Linux.
Thank you for the comment! I already added the implementation which handles key input with KeyboardEvent.key
. I forgot notifying it in this issue..
Ah, cool. Thank you for improving my first impression of NyaoVim then!
No any other problem about Neo2 was reported for 1 week. I think latest version already solved this issue. (I can't confirm it because of not having the keyboard.)
I'll close this window. If anyone notice a problem about this issue, please ping me in this issue. And then I'll reopen this issue.
Sorry, late to the party.
I just retried that and Neo2 is not working for me properly. The Shift and Mod4 modifiers are working, but Mod3 modifiers are not generating the correct symbols. For example, the above mentioned Mod3 + h now inserts Mod3 + h a ¿ instead of ?.
nyaovim --version
NyaoVim version 0.0.12
electron : 0.36.5
chrome : 47.0.2526.110
node : 5.1.1
v8 : 4.7.80.27
@SirVer
Thank you for checking. I'll investigate.
@SirVer
I want to confirm more. Could you tell me your environment (OS X? Linux? if Linux, which distribution? etc)?
@rhysd this is on OS X, still same setup (see above, I posted the debug out some time back).
Ah, sorry for duplicate question. I missed the description. And thank you for the answer, I got it.
I added new property disable-alt-key
to <neovim-editor>
component in ~/.config/nyaovim/nyaovimrc.html
. If this property is on, NyaoVim ignores alt key input so that keyboard which uses alt key as special modifier is available. Please note that <A-x>
mapping will be unavailable.
e.g.
<neovim-editor
id="nyaovim-editor"
argv$="[[argv]]"
font="Monaco,monospace"
font-size="14"
line-height="1.5"
disable-alt-key
></neovim-editor>
To use this, please reinstall nyaovim
package and ensure version ofneovim-component
package is 0.4.4
. (NyaoVim depends on it)
I added this workaround because NyaoVim can't know which alt key or modifier key is pressed from altKey
in KeyboardEvent
.
The neo2 keymap is an ergonomic keyboard layout.
It works great for most apps, but this one is not passing through special keys like ~:? which are using special modifier keys. Atom had similar issues: https://github.com/atom/atom/issues/3834 which leads me to believe that it is probably an issue with many keymaps, not only Neo.