*
* @param f the function to be called
* @param key the key event
*/
public void keyEvent(JsFunction f, int code, int action) {
JsObject event = new JsObject(JsObject.OBJECT_PROTOTYPE);
switch(action){
case Canvas.LEFT:
code = 37;
break;
case Canvas.UP:
code = 38;
break;
case Canvas.RIGHT:
code = 39;
break;
case Canvas.DOWN:
code = 40;
break;
}
event.addVar("keyCode", new Double(code));
synchronized (eventLock) {
stack.setObject(1, this);
stack.setObject(2, f);
stack.setObject(3, event);
f.eval(stack, 1, 1);