x-tag / core

The Heart of X-Tag
http://x-tag.github.io/
Other
1.25k stars 151 forks source link

Enhance tap event for web accessibility #178

Open JustinCreasy opened 6 years ago

JustinCreasy commented 6 years ago

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.

jpecor-pmi commented 6 years ago

KeyboardEvent.which is now deprecated. May want to switch to event.key, or use in addition to event.which.

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

On Thu, Aug 24, 2017 at 9:25 AM, JustinCreasy notifications@github.com wrote:

@JustinCreasy commented on this pull request.

In src/core.js https://github.com/x-tag/core/pull/178#discussion_r135013307:

     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) {

thanks, great suggestion.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/x-tag/core/pull/178#discussion_r135013307, or mute the thread https://github.com/notifications/unsubscribe-auth/AQpkk5OQapO36EKDlmLhia3R7EgBFLiVks5sbXnTgaJpZM4O7tCF .

csuwildcat commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.