Live data from Hacker News

MapKey: jQuery for Keyboard shortcuts

pixelmatrixdesign.com

1–10 of 11 posts

Re: MapKey: jQuery for Keyboard shortcuts

#4
I've been struggling with this for a little bit. I have a web application that I'm developing that needs to support keyboard shortcuts. It's basically a giant SVG element on the page with a toolbar at the top, and some popup windows. The problem seems to be always capturing the keys. As long as the user interacts with the SVG element, everything is fine. However, if they move their mouse over the navigation bar (for instance) absentmindedly, then press "Delete", there seems to be a good chance they will end up "going back" instead of me having a chance to see that keypress and intercept it.

Is there any reliable way that works in modern browsers (Firefox, Chrome, Safari) of capturing all the key events on a page, outside of using something like jquery.hotkeys and just doing:

$(document).bind("keyup", "delete", function() { });

Is $(window) better? Some other element I'm not thinking of?

Re: MapKey: jQuery for Keyboard shortcuts

#5

I've been struggling with this for a little bit. I have a web application that I'm developing that needs to support keyboard shortcuts. It's basically a giant SVG element on the page with a toolbar at the top, and some popup windows. The problem seems to be always capturing the keys. As long as the user interacts with the SVG element, everything is fine. However, if they move their mouse over the navigation bar (for…

I posted this as a question on SO as well: http://stackoverflow.com/questions/4959487/best-way-to-captu...

Just in case someone comes across this later on Google.

Re: MapKey: jQuery for Keyboard shortcuts

#7
I'm not a javascript or jquery guru but from what I can tell it's still not possible to reliably grab all keyboard characters within a browser. Browsers will hijack many combinations - backspace key (some browsers change depending where your mouse is), alt+f, etc. And they're inconsistent in what they grab.

For this reason, I'd still far prefer console applications rather than a browser, despite the rendering advantages you get with a browser.

With a console app, you can easily get to a point where it will always work the same, regardless of the platform your user is on.

Keyboard interaction should be a more important part of desktop computer usage than it is in these modern wimpy systems we use. The state of the browser is the main driver of this.

Re: MapKey: jQuery for Keyboard shortcuts

#9
post #7

I'm not a javascript or jquery guru but from what I can tell it's still not possible to reliably grab all keyboard characters within a browser. Browsers will hijack many combinations - backspace key (some browsers change depending where your mouse is), alt+f, etc. And they're inconsistent in what they grab. For this reason, I'd still far prefer console applications rather than a browser, despite the rendering advanta…

I think things are better than you think. I use keyboard shortcuts extensively on gmail and asana and neither of them feel compromised at all in that department.

Re: MapKey: jQuery for Keyboard shortcuts

#10

This seems neat, but would there be any reason for using this over something like jquery.hotkeys? https://github.com/jeresig/jquery.hotkeys

Straight from the github readme:

More advanced stuff

This plugin is meant to be a very light one. If you need to do more advanced things, I suggest trying jeresig’s plugin jQuery.hotkeys. That can handle things like key combinations and more

Post reply on HN