Mottie / Keyboard

Virtual Keyboard using jQuery ~
http://mottie.github.io/Keyboard/
Other
1.78k stars 723 forks source link

No character input on contentEditable div in IE11 #725

Open danieldriver97 opened 5 years ago

danieldriver97 commented 5 years ago

-- Version 1.28.7 --

Trying to type on a contentEditable div will not display any characters in IE11. This is demonstrable in the Virtual Keyboard demo.

Source of the problem is line 1299 which is called by line 1385.

image

image

Line 1385 passes the 'insertText' command to line 1299 which then calls upon the browser's execCommand function to execute. While supported on modern browsers like Chrome, IE11 does not support the 'insertText' execCommand argument.

Suggested that a check is added in place to see if the browser being used is IE11 and if so, use a different method of appending text to the contentEditable div.

Using the following code somewhat works, but functionality like backspacing and caret updating is buggy. Could be used as a starting point as I've been stumped trying to find a working fix.

base.insertContentEditable = function (txt) { base.$preview.focus(); if (document.all || (!!window.MSInputMethodContext && !!document.documentMode)){ base.execCommand('paste', txt); $keyboard.caret(base.$preview, 'end'); } else{ base.execCommand('insertText', txt); } base.saveCaret(); return base; };

Mottie commented 5 years ago

Hi @danieldriver97!

IE11 bites us again! I'm leaning towards dropping support of IE completely, especially since M$ is going to base their browsers on webkit.