Richard James
Richard James

Reputation: 123

Keydown in jquery - Can I target specific letters with any kind of plugin?

I need to call a function when a certain letter is pressed, i.e. pressing 'l' changes a div's class, and pressing 'g' changes it to another class.

Can this be done natively in jquery, or will I have to find a plugin?

Thanks.

Upvotes: 0

Views: 264

Answers (1)

orolo
orolo

Reputation: 3951

jQuery:

$(document).bind('keydown', function(e) {
   if (e.which == 39) { 
       rightArrowFunction();
   }
});

Upvotes: 2

Related Questions