Contenteditable + preventDefault doesn't work with special key chars
Reported by
nicolas....@peoplbrain.com,
Jun 22 2017
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3135.4 Safari/537.36 Steps to reproduce the problem: 1. Create a Div with Contenteditable=true 2. Add event on KEYUP / KEYDOWN 3. Add a preventDefault 4. Try to edit the contenteditable with special chars like "^", "~" etc. What is the expected behavior? It should not print any chars on key pressed please test on the JSFiddle in comments What went wrong? It's still printing some chars for example, with a FRENCH keyboard, i can tap on the "^" key and after for example "p" key, and it will print "p" on the div. Did this work before? N/A Chrome version: 61.0.3135.4 Channel: dev OS Version: 10.0 Flash Version: https://jsfiddle.net/9dm2nwwL/
,
Jun 22 2017
Do you need more informations on my computer / keyboard configuration ?
,
Jun 22 2017
keydown/keyup won't prevent composition style events (which are IME events). In fact your code wouldn't work on Android either. There currently is no mechanism to prevent composition events. However you can listen to the beforeinput event and determine what it is going to insert.
,
Jun 23 2017
Ok, but prevent event on beforeinput doesn't do anything : https://jsfiddle.net/c2e6zgvu/
,
Jun 23 2017
wrong link : https://jsfiddle.net/c2e6zgvu/2/
,
Jun 23 2017
Chrome only implements beforeinput level 1... https://www.w3.org/TR/input-events-1/
,
Jun 23 2017
So there is no solutions ?
,
Jun 23 2017
You can store the value of your content editable in the beforeinput and restore it in the input event if you like. |
||
►
Sign in to add a comment |
||
Comment 1 by bokan@chromium.org
, Jun 22 2017