Comments (20)
That's probably because the scancode is used.
I wonder if you have tried Atom (the editor), is your keyboard working well there?
from neovim-e.
Keyboard work in Atom Editor.
from neovim-e.
OK, let me see if I can find the issue, as the code that processes keyboard events were taking from Atom.
But it could be difficult as I don't have an Azerty keyboard.
from neovim-e.
Ok. Feel free to ask me to test some modification.
from neovim-e.
I try to replace keydown event by keypress event.
Many character work well (like : ) by i think we must rebind code of function button => actually "z" is bind on F11
from neovim-e.
Indeed the keypress event is the only way to go. AFAIK it's not possible to properly handle localized or punctuation characters via the keydown event. Unfortunately, some special keys like or do not fire the keypress event. So we need to keep both.
I propose to keep keydown for the special keys and then handle others with the keypress event.
I'll fork and try to implement something as a POC. It'll need a lot of tests to handle every cases.
@coolwanglu: you don't need a physical AZERTY keyboard to test. It's depend on which system you are but you can easily change the layout.
from neovim-e.
@q12321q Is there a library for this?
from neovim-e.
for what?
from neovim-e.
Translate keycode to localized characters.
from neovim-e.
Unfortunately, no. There're many attempts but all of them seems clumsy/kludgy and not exhaustive.
If you look on the web about keypress vs keydown, you'll find a lot of guys trying to solve this issue. The only reasonable solution is for me to use the keypress event.
from neovim-e.
And here we are lucky because keycode are also local to every browser. For a same character, you can have different keycode in chrome and firefox...
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
from neovim-e.
I updated the fork (https://github.com/q12321q/neovim-e) with the implementation of my previous comment:
- add keypress event to handle "printable characters"
- keep keydown event for specials characters only
From my first tests, It works pretty well except for Ctrl-NonASCIICharacters: it's major issue since Ctrl-] is a common shortcut. We'll have to think of something.
@coolwanglu what do you think?
from neovim-e.
Some readings:
atom/atom-keymap#37
https://github.com/andischerer/atom-keyboard-localization
It won't be that easy to solve...
from neovim-e.
@q12321q Indeed I switched 'keypress' to 'keydown' before, just to handle special characters. To use both events, we need to make sure that each physical key press is handled only once by either handler, and we might need to test on different platforms.
atom-keyboard-localiztion
looks neat, do you think we can use its code?
from neovim-e.
I start to think that the keypress solution is maybe a dead end...
I'm not sure we will be able to handle the Ctrl chords like that.
Keypress give us the charCode of the result of Ctrl-a but not the charCode of "a" + the fact that with use Ctrl. So I can't build the string "< C-a >" to send to nvim but instead I directly send the character itself. I'm fortunate that it works with a but it doesn't for all non ASCII and punctuation characters.
I'll look a bit more into atom-keyboard-localization
from neovim-e.
Indeed. That's quite a mess.
Hopefully with the localization module, a mapping can be chosen based on the keyboard layout specified by users, and the key events will be simply mapped accordingly.
Good luck!
from neovim-e.
OK, I did some search again and I found no perfect solution. Atom has the same issues and like us have no clean solution. atom-keyboard-localization fix a lot of things but has the major drawback to maintain a non exhaustive tables of key mappings and the need to manually define on which keyboard you are.
But we have a hope: DOM3 with the implementation of the key value in the keydown event:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
It'll solve all our problems and will drastically lighten the code.
The problem is it's not yet implemented in chrome:
https://www.chromestatus.com/feature/4748790720364544
They're working on it and we may hope to have it soon.
Firefox has already done the job and you can try it on the lastest version with this page:
https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html
In the mean time if you want, we can implement something like atom do:
- keypress handle all singles characters without Ctrl or Alt
- So all international and punctuation characters are handle
- Dead keys are handle ( ^ + e -> ĂȘ)
- Alt+Number works ( Alt+0199 -> Ă)
- keydown handle special keys and key combination
- Use localized keycode tables like atom-keyboard-localization to handle Ctrl+, Alt+ and Meta+
- had a option somewhere to select localized layout
You'll always have the correct character when typing a text and we could only have limitations on key combinations.
Thoughs?
from neovim-e.
I don't know how long we should wait for KeyboardEvent. I remember our keydown
and keypress
events can also be simplified with it.
So it depends on whether you want this feature in the near future.
from neovim-e.
Of course it could take at least several months or years to wait for the KeyboardEvent.key feature. Dev is always longer than we think but it's good to know that we'll have a real solution.
It's pretty important for a text editor to be reliable while typing characters :)
Today, neovim-e is unusable on non-US keyboard: the ':' is not available.
It also depends how much you want to invest into neovim-e: is it a POC or a real software with a futur?
from neovim-e.
@q12321q It started as a simply POC, or a toy :). But I'm happy to find that people started to report bugs and send PRs. While I will have limited time on this project, I'd love to make fixes and merge PRs.
from neovim-e.
Related Issues (20)
- [idea] Full screen mode like iTerm (doesn't go into it's own workspace). HOT 1
- Slow scroll HOT 4
- Closing the electron window doesn't exit neovim cleanly HOT 2
- [idea] Prevent cursor blink when moving the cursor.
- (Windows) crashes when switching splits
- [BUG] Scrolling with mouse scrolls wrong window (top left window).
- [idea] Fontsize should change when pressing Meta + "0, -/_, +/=" keystroke
- [idea] Use one.js for WebGL font rendering. HOT 4
- HiDPI on Linux. HOT 4
- Please set up bounty source so people can support your work. HOT 2
- Popup menu flickers while typing. HOT 6
- Support ligatures. HOT 2
- [bug] <c-w> closes Neovim-e in Linux. HOT 2
- Cannot map command keys
- Crashes on creating a new split HOT 5
- How to change the line height? HOT 1
- [idea] command line binary
- cmd -> ctrl option in OS X HOT 7
- Misrepresented?
- Cannot find module 'app' HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â€ïž Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neovim-e.