New issue
Advanced search Search tips

Issue 679439 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug


Show other hotlists

Hotlists containing this issue:
Hotlist-1


Sign in to add a comment

KeyboardEventInit doesn't support supplementary codes

Project Member Reported by w...@chromium.org, Jan 9 2017

Issue description

Chrome Version: 57.0.2970.0 dev

What steps will reproduce the problem?
(1) Create a KeyboardEvent with a specific |keyCode| value, e.g. var foo = new KeyboardEvent("keydown", { "keyCode": 45 })

What is the expected result?

|foo| should be a KeyboardEvent with |keyCode| set to 45.

What happens instead?

KeyboardEvent has |keyCode| set to zero.

Although |keyCode| is a deprecated DOM KeyboardEvent field, it should be possible to set it in synthetic events, to allow injection of input to legacy content.

Note that although we could synthesize |keyCode| from |key|/|code|, doing so is not straightforward unless we assume some default layout, which is undesirable.
 
Labels: Hotlist-Input-Dev Hotlist-Interop
Owner: dtapu...@chromium.org
Status: Assigned (was: Untriaged)
Summary: KeyboardEventInit doesn't support supplementary codes (was: keyCode parameter to KeyboardEvent constructore is ignored, and results in events with keyCode=0)
Chrome doesn't support these: https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit
In this case I was attempting to inject keystrokes into some legacy content, the HTML5/JS game braains.io

These were the docs I was trying to follow:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent

This is the hack people use to work around it:

var eventObj = document.createEvent("Events");
eventObj.initEvent("keydown", true, true);
eventObj.keyCode = keyCode;
eventObj.which = keyCode;    
document.dispatchEvent(eventObj);

SO has some discussion http://stackoverflow.com/questions/8942678/keyboardevent-in-chrome-keycode-is-0/12522752

Labels: M-65
Status: Fixed (was: Assigned)

Sign in to add a comment