syntax - How to fire event in Javascript (with KineticJs) upon spacebar or arrowkey keystroke -


how 1 fire event in javascript upon space bar click or arrow key strike? using kineticjs framework, although may irrelevant may able done in regular javascript. thanks!

kineticjs doesn't handle keyboard events , don't think 1 day kinetic used html5 canvas javascript framework.

but kineticjs compatible jquery can provide need.

here example :

 $(document).keydown(function(event){          console.log("key index : " + event.which);          if (event.which == 38) {          //up                                                                           console.log("up");             event.preventdefault();         } else if (event.which == 37) {   //left                                                                         console.log("left");             event.preventdefault();         } else if (event.which == 39) {   //right                                                                         console.log("right");             event.preventdefault();         } else if (event.which == 40) {   //down                                                                         console.log("right");             event.preventdefault();         }  } 

hope you.

xavier


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -