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 -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -