Possible bug: Backspace after input of composed characters via layoutCandidates

This issue has been tracked since 2022-09-26.

Simple-keyboard version

Describe the bug

  1. Have a layout file containing "composed" characters like Î in "layoutCandidates" (see below).
  2. Enter such a character to the input field by clicking ^ on the "regular" virtual keyboard and then selecting Î from the layoutCandidates box.
  3. Now hit "backspace": The Î seems to be decomposed in that it changes to I. "backspace" has to be pressed a second time to remove this "residue". This does not happen if a composed character was entered with a button of the "regular" virtual keyboard.

This happens in Firefox 105.0.1 as well as in Microsoft Edge 105.0.1343.50 (both running on Windows 10 64bit) as well as in chromium 92.0.4515.98 on a Raspberry Pi running Raspbian 10.

Unfortunately I was not able to recreate this behaviour in a CodeSandbox where I modified the chinese layout demo, So I attach a .zip file whoch contains "index.html", "index.js" and "index.css" from the chinese language demo but especially "testlayout.js" which has the following layoutCandidates:

layoutCandidates: {
    '^': '^ â Â ê Ê î Î ô Ô û Û',
    '¨': '¨ ä Ä ë Ë ï Ï ö Ö ü Ü ÿ',
    '~': '~ ã Ã ñ Ñ õ Õ',
    '`': '` à À è È ì Ì ò Ò ù Ù'

The "index.html" and "index.js" files have been modified so they can be used when delivered from a local http server (used nginx here).

hodgef wrote this answer on 2022-09-30

Hey @gvolt, this is intended behavior. Here's the reasoning behing this:

#1398 (comment)

Francisco Hodge

gvolt wrote this answer on 2022-09-30

Hi @hodgef,

many thanks for your fast response.

Is there a method to change this behaviour so clicking "backspace" once would erase the decomposed character?

gvolt wrote this answer on 2022-09-30

Thank you very much for considering this as an enhancement.

For now I am using

function onChange(input) {
  document.querySelector(".input").value = input.normalize('NFC');
  keyboard.setCaretPosition(keyboard.getCaretPosition() - input.length + input.normalize('NFC').length);
  console.log("Input changed", input);

in order to make sure a composed character is written to the input field and to correct the caretPosition if necessary.

hodgef wrote this answer on 2022-09-30

Hey @gvolt, feel free to try out the new option disableCandidateNormalization.
It is available as of the latest version of simple-keyboard.

Francisco Hodge

gvolt wrote this answer on 2022-09-30

Most excellent! Just tried it and works as expected. Thank you very much!

More Details About Repo
Owner Name hodgef
Repo Name simple-keyboard
Full Name hodgef/simple-keyboard
Language JavaScript
Created Date 2018-03-02
Updated Date 2022-12-02
Star Count 1737
Watcher Count 20
Fork Count 130
Issue Count 0


Issue Title Created Date Updated Date