Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Alt modifier keys not working in chrome on mac but works in windows. #31

Open
3 of 8 tasks
anandanand84 opened this issue Oct 21, 2016 · 3 comments
Open
3 of 8 tasks
Assignees

Comments

@anandanand84
Copy link

anandanand84 commented Oct 21, 2016

Description

The iron-ally-keys element does not work with alt modifier in chrome,firefox,opera on mac. But works with safari and windows. It can be seen in the demo page. https://elements.polymer-project.org/elements/iron-a11y-keys?view=demo:demo/index.html&active=iron-a11y-keys Navigate to demo page in chrome on mac and press alt+a

Expected outcome

It should display alt+a.

Actual outcome

Nothing is displayed

Live Demo

https://elements.polymer-project.org/elements/iron-a11y-keys?view=demo:demo/index.html&active=iron-a11y-keys

Steps to reproduce

  1. Navigate to https://elements.polymer-project.org/elements/iron-a11y-keys?view=demo:demo/index.html&active=iron-a11y-keys in chrome on mac
  2. press alt+a.

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@anandanand84 anandanand84 changed the title Alt modified keys not working in chrome on mac but works in windows. Alt modifier keys not working in chrome on mac but works in windows. Oct 21, 2016
@valdrinkoshi
Copy link
Member

alt + a produces a keyboard event which has event.key = 'å'. I'm not sure this can be solved by iron-a11y-keys, as it's clearly a different behavior on what's returned by the event.key.

@rshmtud
Copy link

rshmtud commented Sep 15, 2017

+1

@freshp86
Copy link
Contributor

freshp86 commented Nov 11, 2019

@danbeam

alt + a produces a keyboard event which has event.key = 'å'. I'm not sure this can be solved by iron-a11y-keys, as it's clearly a different behavior on what's returned by the event.key.

Actually, the problem is not the fact that a key like "å"is produced. Even if one registers a keyboard shortcut as follows on Mac, it does not trigger at all.

behaviors: [
  Polymer.IronA11yKeysBehavior,
],
keyBindings: {
  'alt+ç': 'onMyShortcut_',
},

Digging through the code, there seems to be an arbitrary limitation in iron-a11y-keys-behavior, at
https://github.com/PolymerElements/iron-a11y-keys-behavior/blob/dd98dccceb6db2d8fab9204d0bc45a192911c7f6/iron-a11y-keys-behavior.js#L190-L191, where only alpha-numeric keys are allowed when modifiers are used.

// For combos with modifiers we support only alpha-numeric keys
var keyEvent = normalizedKeyForEvent(event, keyCombo.hasModifiers);

Further following this codepath, it goes into transformKey at https://github.com/PolymerElements/iron-a11y-keys-behavior/blob/dd98dccceb6db2d8fab9204d0bc45a192911c7f6/iron-a11y-keys-behavior.js#L104, which basically converts "ç" to the empty string, therefore causing such shortcuts to never fire.

Is there a good reason for this limitation? If noSpecialChars is always passed as false then shortcuts like Alt+c on Mac work fine, as long as they are registered in the code as alt+ç.

Or at the very least, there should be a way to turn off the noSpecialChars logic from a specific element that uses the IronA11yKeysBehavior.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants