New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 735940 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Contenteditable + preventDefault doesn't work with special key chars

Reported by nicolas....@peoplbrain.com, Jun 22 2017

Issue description

UserAgent: 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/
 

Comment 1 by bokan@chromium.org, Jun 22 2017

Components: -Blink Blink>Input
I can't repro on the attached jsfiddle but I'm guessing this may be related to keyboard language/IME.
Do you need more informations on my computer / keyboard configuration ?
Cc: dtapu...@chromium.org chongz@chromium.org
Status: WontFix (was: Unconfirmed)
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.
Ok, but prevent event on beforeinput doesn't do anything :

https://jsfiddle.net/c2e6zgvu/
Chrome only implements beforeinput level 1... https://www.w3.org/TR/input-events-1/
So there is no solutions ?
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