I need to be able to get extract what key was pressed (looking for Escape, Enter keys).
I've just looked into the various docs [1][2][3], and they seem to suggest that:
The KeyboardEvent was briefly (from 2003-2010) defined to have keyIdentifier and keyLocation attributes, but these were removed in favor of the current key and location attributes. These attributes were not widely implemented.
But when using the latest stable Chrome and Safari, I'm seeing the opposite. key is not present at all, but keyIdentifier is set. With this test page,
I need to be able to get extract what key was pressed (looking for Escape, Enter keys).
I've just looked into the various docs [1][2][3], and they seem to suggest that:
But when using the latest stable Chrome and Safari, I'm seeing the opposite.
key
is not present at all, butkeyIdentifier
is set. With this test page,This is what I'm seeing:
The only two fields that I see to identify which key was pressed are
keyCode
andkeyIdentifier
.Can you please add one of them? Or if I'm mistaken, suggest how I can determine if Escape or Enter were pressed using existing API.
I think I would prefer
keyIdentifier
(overkeyCode
) if it indeed is the current "standard". But I'm not opposed to you adding both.[1] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent [2] http://www.w3.org/TR/DOM-Level-3-Events/ [3] http://unixpapa.com/js/key.html