5 ms·
MapKey: jQuery for Keyboard shortcuts
- LiveTheDream 16y agohttp://www.openjs.com/scripts/events/keyboard_shortcuts http://www.openjs.com/scripts/events/keyboard_shortcuts shortcut.add("Up",function() { // code to go up });
- Pewpewarrows 16y agoThis seems neat, but would there be any reason for using this over something like jquery.hotkeys? https://github.com/jeresig/jquery.hotkeys https://github.com/jeresig/jquery.hotkeys
- abp 16y agoStraight 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
- bigfudge 16y agolast time I looked hotkeys was tied to and old (<1.3) release of jquery too. EDIT: I was wrong. Rewritten in Jan this year to work with 1.4.2, which is really good news. https://github.com/jeresig/jquery.hotkeys https://github.com/jeresig/jquery.hotkeys
- silverlight 16y agoI'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?
- silverlight 16y agoI posted this as a question on SO as well: http://stackoverflow.com/questions/4959487/best-way-to-capture-all-key-events-for-a-web-application http://stackoverflow.com/questions/4959487/best-way-to-captu... Just in case someone comes across this later on Google.
- wookiehangover 16y agothis is really just a wrapper .keypress() with the char codes mapped... so to bind an event handler to a single keypress, you're adding 3kb of js for something jQuery already provides an interface for. placet cuique suum.
- cturner 16y agoI'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.
- famousactress 16y agoI 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.
- paydro 16y agoI created a similar plugin, but it uses a Vi-like binding schema. https://github.com/paydro/keylock https://github.com/paydro/keylock