Comments (14)
BTW, for looking at key events, you may want to try: https://w3c.github.io/uievents/tools/key-event-viewer.html
You can turn on keyIdentifier
by selecting Options and enabling the "Old DOM3" fields.
from iron-a11y-keys-behavior.
I'm confused as to why this bug was closed. Even if the root cause is due to a platform issue, there is surely a problem with iron-a11y-keys-behavior as well.
The documented behavior is you put a character as a key in the keyBindings object, you get a key binding for the key that generates that character. If this works only for some characters, then you need to document what subset of characters it works for.
And honestly, as an application developer, if I can't count on this library to work for every key I need to handle bindings for, I'm not likely to use it at all. Handling some key events using this behavior and some manually is more conceptual overhead than just handling everything manually.
from iron-a11y-keys-behavior.
/ is not the only key affected. For example [ shows up as U+00DB and ] is U+00DD.
from iron-a11y-keys-behavior.
Additionally, on Windows, [ is reported as U+00DD.
from iron-a11y-keys-behavior.
event.keyCode
is not reliable for special characters (e.g. on US keyboard you'd press shift
and 1
to obtain !
The resulting event.keyCode
is 49 which corresponds to 1
, that's why we rely on event.key
, then event.keyIdentifier
and finally event.keyCode
)
event.key
should be the answer, but so far it is undefined for special characters. So next best is event.keyIdentifier
.
Did some tests, on Chrome Linux the event.keyIdentifier
is wrong:
# pressed /
key undefined ->
keyIdentifier U+00BF -> ¿
keyCode 191 -> undefined
# pressed [
key undefined ->
keyIdentifier U+00DB -> û
keyCode 219 -> undefined
On Chrome Mac instead event.keyIdentifier
is correct:
# pressed /
key undefined ->
keyIdentifier U+002F -> /
keyCode 191 -> undefined
# pressed [
key undefined ->
keyIdentifier U+005B -> [
keyCode 219 -> undefined
Adding 191 keyCode is not an option, because it would be triggered even if we press Shift + [
(which instead matches to {
).
from iron-a11y-keys-behavior.
Closing this issue as it's a platform problem rather than of the behavior.
@cdata FYI
from iron-a11y-keys-behavior.
Have you filed a Chrome bug for this? Is the problem also present on Firefox Linux?
from iron-a11y-keys-behavior.
This issue happens only on Chrome on Linux and Windows, Firefox already implements event.key
and returns the correct values.
I've reported the issue on chromium
@dborowitz iron-a11y-keys-behavior
supports special characters to the extent of how they're supported by the platform :)
Even if you want to handle it without using this element, you'll face the same issues with other keyboard configurations.
In your case you want to listen to /
: with a US keyboard you'd check for keyCode = 191
and make sure that event.shiftKey = false && event.altKey = false
in order to avoid recognizing characters like ÷
(which is Alt+/
) and ?
(which is Shift+/
).
With a French keyboard you need to press Shift+:
to obtain /
, so you see how difficult it becomes to handle everything properly without something like event.keyIdentifier
or (even better) event.key
from iron-a11y-keys-behavior.
Surprise surprise: on keypress
event everything works as expected! http://jsbin.com/webogoc/4/edit?html,output
I'll reopen this issue, I'll update the demo page to use keypress for the special characters ;)
from iron-a11y-keys-behavior.
Ok, closing this again. On Linux the keyIdentifier
is wrongly set also for keypress
, and we cannot bypass it and prefer keyCode
for the reasons I exposed before
In this test i pressed /
and then [
, and we get the final result via normalizedKeyForEvent
from iron-a11y-keys-behavior.
Please re-open this as keyIdentifier
is deprecated in favor of key
and the Blink bug was closed as WontFix. https://crbug.com/587150
/cc @garykac
from iron-a11y-keys-behavior.
Hm. On Chrome Canary (52.0.2734.0) key
is supported.
@valdrinkoshi will this “just work” once key
is supported given the key handling code and it’s various fallbacks?
from iron-a11y-keys-behavior.
key
is supported on Chrome 51+ and we should fix any bugs that relate to key
and code
. Recent versions of Opera will have this support as well. Firefox already supports both of these attributes. IE/Edge have an older implementation of key
that they will be updating at some point (probably when they add support for code
).
from iron-a11y-keys-behavior.
Correct, the behavior will first try to use key
and then the others if that's not available.
from iron-a11y-keys-behavior.
Related Issues (20)
- Please improve documentation.
- 'esc' not matched for escape key in Chrome Canary, breaking menus HOT 2
- add support for "only" modifier HOT 3
- Autofill causing exceptions HOT 2
- handle keyEventTarget = null
- need to check for null keyEventTarget
- 'KeyboardEvent.keyIdentifier' is deprecated warning in Chrome HOT 6
- demo's tilde key not working on mac french keyboard
- KeyBinding erroneously fired when modifiers are pressed HOT 1
- _unlistenKeyEventListener fails when _boundKeyHandlers is undefined HOT 4
- Numpad "+", "-" and "/" not detected in IE/Edge HOT 1
- this.behaviors property is not available in native 2.0 class-based element HOT 1
- Using iron-a11y-keys-behavior on native elements? HOT 1
- Bug on with Polymer 2 (key events aren't catched) HOT 2
- IronA11yKeysMixin
- iron a11y keys behavior not working polymer 2.x HOT 1
- Can't listen for alt, meta, or shift
- Dynamically add key binding in polymer
- Polymer 3.2: TypeError cannot convert null to object HOT 9
- Uncaught TypeError: Cannot convert undefined or null to object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iron-a11y-keys-behavior.