Closed romgrk closed 8 years ago
Actually let me run some tests. Getting weird results when using non-US layout.
So, this setup seems to work for all cases on my side, but let me know what you think, the documentation is vague on some aspects.
(Not to mention the This article is in need of a technical review.
at the top of the MDN doc)
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
I also tried KeyboardEvent.key
now with Electron 0.36.3 but it didn't work.
Below is a keydown
event for Alt+a
in OS X:
The key
is wrongly å
. This is because OS X handles Alt+a
in OS level. I think #14 is still there.
And second case is Ctrl+a
:
The key is empty. I don't check the spec of KeyboardEvent.key
tightly, but I guess that Ctrl+a
makes no character input so the key is empty.
But this is no problem, we can parse KeyboardEvent.code
to get correct key user entered. I'll totally rewrite keydown
event handling.
Ya, I'll let you go ahead with KeyboardEvent.code
, the specs for .key
seems to vary a lot from one OS to another. Let me know if you need help for testing. (I have various linux/windows versions).
Oh, and btw this is good to know:
From some tests I have run here, the key
property might appear as empty in the console (shown as ""
), but it is actually equal to something else.
In my case it was equal to '\u000E'
, therefore it was showing as ""
, but event.key == ""
was false
. (This is actually in the specs I think)
From some tests I have run here, the key property might appear as empty in the console (shown as ""),
Oh, I seemed to misunderstand it. I'll consider again and implement key handling. Thanks!
Anyway, Alt+{char}
inputs in OS X is an edge case. I might handle them exceptinally :pensive:
I never ever coded in typescript, but I've run the build here, and all works fine. Dont hesitate to discard and use your own implementation.