Physical keyboard events on desktop

I’d like to create a desktop version of my game using Cocos2d-x. I’ve already compiled it and ran on Linux. Cocos2d-x is great!

Is it possible to capture keyboard events (KeyUp, KeyDown) on desktop? I want to replace touch and accelerometer events for pressing Arrow Up, Down or Space Bar in a physical keyboard.

I’ve found some methods (like ccKeyUp and ccKeyDown) in documentation, but couldn’t understand how to use them.

Thanks!

ccKeyUp and ccKeyDown is used for android keys.
You should modify engine to capture keyboard events and deliver it to engine.

When will we no longer need to hack the engine for keyboard events?

For Google incomers, as of today keyboard is supported in github’s develop branch.
Look for KeyboardTest.cpp inside TestCpp sample.

Diego Ponciano wrote:

For Google incomers, as of today keyboard is supported in github’s develop branch.
Look for KeyboardTest.cpp inside TestCpp sample.

see http://www.cocos2d-x.org/boards/6/topics/28973?r=29622 for more info :slight_smile: