[Resolved]troubles with keyboard handler


#1

Hello.
I try to make some things with keyboard buttons. But my program never go into keyDown:function and keyUp:function.
In my layer’s init I make this.setKeypadEnabled(true);
Also I create in layer
onEnter:function(){
this._super();
},
But when I put brealpoint in keyDown:function - nothing. Help me, please!
Thanks.


#2

>*<

we found a BUG in CCDirector.js
if yuo have troubles with this, edit CCDirector.js according to this:
//KeypadDispatcher
this.*keypadDispatcher = new cc.KeypadDispatcher.getInstance();


#3

KeyboardDispatcher should be singleton in the project.

Could you please provide us any code to reproduce the issue?


#4

Hello, Shun Lin.

In previous version of cocos2d-html5 (Cocos2d-html5-v0.5.0-alpha2) in file CCDirectod.js keypad dispatcher inited by this way:
//KeypadDispatcher
this.*keypadDispatcher = new cc.KeypadDispatcher;
This is wrong. But now I see the new version of cocos2d and ther in CCDirector.js keypad dispatcher inited by this way:
//KeyboardDispatcher
this.*keyboardDispatcher = cc.KeyboardDispatcher.getInstance();

And this is correct. So, you don’t need any updates in this error, because the new version is all fixed.
Thanks.


#5

Not sure if this helps but if the cocos2d-x team wants to add it then this should help. See this post:

[[http://www.cocos2d-x.org/boards/6/topics/15228]]

This is for OSX platform so someone would need to add Unix and windows platforms by modifying the corresponding EAGLView class.