x-keyboard
x-keyboard copied to clipboard
Don’t remove last char when deadkey is pressed.
As I stated in #29, dead keys remove the last character of the input field. I included a gif bellow to show how to reproduce the bug (just type something, then input a dead key other than 1dk
).
This is because when a deadkey is pressed, the event listner in demo.js
is called twice in quick succession. It’s supposed to be called once, to delete the key hint the browser automatically writes (since x-keyboard gives way better hints), but the extra call also deletes another character.
Logging those events (see gif, on the right hand side) shows they are basically the same, except the first event has the isComposing
field set to true
and the second one to false
.
Removing the last char only when event.isComposing
is set to true
fixes that problem, and seems to be the only event we care about, if I understand MDN’s documentation correctly, though there may be an edge case I don’t know about (god knows JS has a lot of those…).
This is really peculiar. I can’t reproduce the bug you’ve explained with so much detail, and your patch introduces a regression on my side — with Ergo-L 0.99.2, pressing 1dk
inputs an o
in my input area. However, your screencast leaves no doubt about the bug…
Wild guess : this happens because you already type in Ergo-L in the Ergo-L emulation input, and I’m using Lafayette.
So we do have an issue here, but we need to nail it very precisely.