javascript - jQuery: How to make keyboard Event do the same on click event together -


i need make click event , arrow right make same event

so instead of repeated code

$('#foo').on('click',function() {     //do });  $(document).keydown(function(e){    if (e.keycode == 39) {     //do same thing above    } }); 

how should it?

thank :)

make them both trigger same function.

$('#foo').on('click', coolfunction);  $(document).keydown(function(e){    if (e.keycode == 39) {     coolfunction();    } });  function coolfunction() {   //same thing } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -