1

I am a beginner in limeJS i want to know how to handle keyboard events in a game using limejs for html5.If one have a source link for it please help me.

Villan
  • 730
  • 1
  • 8
  • 26

2 Answers2

3

Since Lime is built on Closure, you can just use its native event library.

For example:

goog.events.listen(rootLimeNodeObject, goog.events.EventType.KEYUP, function (ev) {
  if (ev.keyCode === 37) { // left arrow
    ...
  }
});
simianarmy
  • 1,485
  • 10
  • 13
2

the guides look pretty obscure, but i would recomend that you use a seperate library like Keyboard js. It's a really good library for keyboard events and it would be the easiest option.

http://robertwhurst.github.com/KeyboardJS/

a demo would be:

KeyboardJS.bind.key('a', onDownCallback(), onUpCallback() );

and this for multiple keys:

KeyboardJS.bind.key('a + b ', onDownCallback(), onUpCallback() );
JqueryToAddNumbers
  • 1,063
  • 3
  • 14
  • 28