Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance tap event for web accessibility #178

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JustinCreasy
Copy link

The tap event as it works now is not fully accessible. This PR add a keypress check for the enter key and the spacebar and treats them as tap events as well.

src/core.js Outdated
condition: function(event, custom){
if (event.type == 'pointerdown') {
custom.startX = event.clientX;
custom.startY = event.clientY;
}
else if (event.type == 'keypress') {
if (event.which == 13 || event.which == 32) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simplifying to: return event.which == 13 || event.which == 32;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, great suggestion.

@jpecor-pmi
Copy link

jpecor-pmi commented Aug 24, 2017 via email

@csuwildcat
Copy link
Member

Per @jpecor-pmi's correct assertion about the deprecation of which, if you (@JustinCreasy) can modify your pull to use the newer property for key code, I can accept it.

Also, can you do the same thing in the core-2 repo when we release the alpha this week?

@JustinCreasy
Copy link
Author

That works, I'll get either event.which or event.key worked in there. A bit swamped at work at the moment but hopefully soon.

I can definitely make the updates again on core-2.

@jpecor-pmi
Copy link

It looks like KeyboardEvent.keyCode and KeyboardEvent.charCode are also deprecated, so I'd recommend using KeyboardEvent.key, which is supported by everything, including Internet Explorer (back to version 9).

@JustinCreasy
Copy link
Author

ok, I have switched to KeyboardEvent.key, as suggested by @jpecor-pmi

I'm a bit concerned because while KeyboardEvent.which is deprecated it has much better support in older browsers than KeyboardEvent.key ( according to http://caniuse.com ). When I get a chance I'll try to test things on a virtual machine running a browser like Chrome v49 to see if I can work up a solution that uses both.

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

Successfully merging this pull request may close these issues.

3 participants