arrow-keys

Detecting Arrow key press in IE via javascript/jQuery

孤人 提交于 2019-11-29 03:27:48
I'm trying to set up a menu that can be navigated via the arrow keys. I have this working fin in Firefox. Trying to get it to work in IE8 and after a bit of struggle, found that it was because IE8 wouldn't register a keypress on the arrows. To test: $(document).keypress(function (eh){ alert(eh.keyCode); }; In Firefox, pressing any of the arrow keys would trigger an alert of 37, 38, 39 or 40. In IE8, nothing. Any other key on the standard QWERTY keyboard would register, but not the arrow keys. Is this an issue with my Javascript? A browser setting? A Windows setting? From the jQuery keypress

How can I respond to external keyboard arrow keys?

醉酒当歌 提交于 2019-11-28 17:19:59
I know this has been asked before, and the only answers I've seen are "Don't require an external keyboard, as it goes against UI guidelines". However, I want to use a foot pedal like this: http://www.bilila.com/page_turner_for_ipad to change between pages in my app (in addition to swiping). This page turner emulates a keyboard and uses the up/down arrow keys. So here is my question: how do I respond to these arrow key events? It must be possible as other apps manage, but I'm drawing a blank. For those who are looking for a solution under iOS 7 - there is a new UIResponder property called

Using arrow keys with jQuery scrollTo

被刻印的时光 ゝ 提交于 2019-11-28 12:49:51
I have successfully implemented the scrollTo jQuery plugin which scrolls to the next div with the class "new" when a link is clicked. However, I would also like to be able to use the arrow keys to scroll up and down to the next/previous divs of the same class. I have looked all over the internet but have been unable to find out how to do this. I am very new to JS so very simple instructions would be appreciated! Here is the relevant code: <script type="text/javascript"> jQuery(function($){ $('<div id="next_arrow"></div>') .prependTo("body") //append the Next arrow div to the bottom of the

Navigate through list using arrow keys? (JavaScript/JQ)

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 04:46:40
I can't seem to find an answer to how to accomplish this, yet it's a feature I've seen several times. Essentially I'm echoing out a list and I would like to create the ability to highlight and select these items using arrow keys/enter. Can someone help give me an idea as to how I can accomplish this? I know how to use keycodes (of course), just not how to turn that into functioning code for selecting items on a list... I was thinking maybe I'd have to have some sort of hidden radio button to mark it as selected or not... but even then I don't know how I would jump from one radio button to the

How can I respond to external keyboard arrow keys?

落爺英雄遲暮 提交于 2019-11-27 20:05:39
问题 I know this has been asked before, and the only answers I've seen are "Don't require an external keyboard, as it goes against UI guidelines". However, I want to use a foot pedal like this: http://www.bilila.com/page_turner_for_ipad to change between pages in my app (in addition to swiping). This page turner emulates a keyboard and uses the up/down arrow keys. So here is my question: how do I respond to these arrow key events? It must be possible as other apps manage, but I'm drawing a blank.

How do I prevent scrolling with arrow keys but NOT the mouse?

时光毁灭记忆、已成空白 提交于 2019-11-27 18:44:50
Since I'm using jQuery, any solution via that would work too. Ideally, I'd like to know both, though. I already have the arrow keys bound to another function on my page (using jQuery), but having them cause the page to scroll in addition to that, causes me problems. I may have known this at one time, but I don't remember it anymore. TheVillageIdiot Adding document level keypress handler does the trick! var ar=new Array(33,34,35,36,37,38,39,40); $(document).keydown(function(e) { var key = e.which; //console.log(key); //if(key==35 || key == 36 || key == 37 || key == 39) if($.inArray(key,ar) > -1

jQuery Move div with arrow keys

烈酒焚心 提交于 2019-11-27 18:39:05
问题 I'm trying to move a div using the arrow keys. I have the following code which is not working for me. Do you see anything wrong with it. Check jsfiddle at http://jsfiddle.net/N5Ltt/1/ $(document).keydown(function(e) { switch (e.which) { case 37: $('div').stop().animate({ left: '-= 10' }); //left arrow key break; case 38: $('div').stop().animate({ top: '-= 10' }); //up arrow key break; case 39: $('div').stop().animate({ left: '+= 10' }); //right arrow key break; case 40: $('div').stop()

Simulate left and right arrow key event with javascript

孤者浪人 提交于 2019-11-27 14:06:57
I'm using the slide.html5rocks.com framework and I'm trying to use to img tags inside of a tag links and I can't get the JavaScript onclick to simulate the left and right key events to change slides You're looking for something that will dispatch an event. Here's something that should work: function fireKey(el) { //Set key to corresponding code. This one is set to the left arrow key. var key = 37; if(document.createEventObject) { var eventObj = document.createEventObject(); eventObj.keyCode = key; el.fireEvent("onkeydown", eventObj); }else if(document.createEvent) { var eventObj = document

Navigate through list using arrow keys? (JavaScript/JQ)

萝らか妹 提交于 2019-11-27 00:39:28
问题 I can't seem to find an answer to how to accomplish this, yet it's a feature I've seen several times. Essentially I'm echoing out a list and I would like to create the ability to highlight and select these items using arrow keys/enter. Can someone help give me an idea as to how I can accomplish this? I know how to use keycodes (of course), just not how to turn that into functioning code for selecting items on a list... I was thinking maybe I'd have to have some sort of hidden radio button to

How do I prevent scrolling with arrow keys but NOT the mouse?

淺唱寂寞╮ 提交于 2019-11-26 19:35:08
问题 Since I'm using jQuery, any solution via that would work too. Ideally, I'd like to know both, though. I already have the arrow keys bound to another function on my page (using jQuery), but having them cause the page to scroll in addition to that, causes me problems. I may have known this at one time, but I don't remember it anymore. 回答1: Adding document level keypress handler does the trick! var ar=new Array(33,34,35,36,37,38,39,40); $(document).keydown(function(e) { var key = e.which; /