Cenzy Digeno
Cenzy Digeno

Reputation: 61

In jquery:event key and mouse together?

I have a slide of test with arrow for the next slide. I want go to next slide also with key(arrow). How can I this in Jquery?

Upvotes: 0

Views: 28

Answers (1)

Jack C
Jack C

Reputation: 1084

You can use e.which to find the value of the key pressed. I believe e.which returns:

37 - left arrow

38 - up arrow

39 - right arrow

40 - down arrow

Simply check for whichever number e.which returns

$(function(){
    $('html').keydown(function(e){
       $('#keypress_con').text(e.which);
    });
});

Here is a link to a JSFiddle that you can use as an example to catch arrow key press events:

http://jsfiddle.net/SLtFk/1/

Upvotes: 1

Related Questions