CodeMirror + virtual keyboard

I have a virtual keyboard plugin with which someone asked if it could be attached & used with CodeMirror.

The result is this demo:

The main issue I’ve encountered is getting the backspace key to work - I can deal with getting the delete key to work later:

  1. The backspace key does not work on text that already exists inside the editor.
  2. It does work on newly entered text entered using either the physical or virtual keyboard.
  3. It doesn’t work if you type in a space. The backspace does not work on spaces
  4. And once a space or carriage return are used, the previously entered text cannot be deleted using the backspace.
  5. After using the carriage return, the first and/or second character of the new line cannot be deleted using the backspace.

I don’t know if these issues are due to the “delCharBefore” command not working as intended, or if there is some conflict with cursor placement between the keyboard code & CodeMirror.

Any input would be appreciated,

Most likely, no actual key event is being fired for backspace in some situations. You could try setting the inputStyle: "contenteditable" option, and see if it helps.

Sadly, the caret positioning code in the keyboard plugin is not yet compatible with contenteditable elements.