8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cocos2d-x 3.1 では Android のバックキーのキーコードは `KEY_ESCAPE` を使う。

Posted at

3.0 までは KEY_BACKSPACE が使われていましたが、 3.1 からは KEY_ESCAPE を使うようです。

こんな感じ。

auto listener = EventListenerKeyboard::create();
listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* unused_event) {
    if (keyCode == EventKeyboard::KeyCode::KEY_ESCAPE) {
        CCLOG("Back!");
    }
};

理由は、

Because desktop and mobile phones share the same key code, and escape is used as back menu on desktop.
https://github.com/cocos2d/cocos2d-x/pull/6853#issuecomment-43706077

だそうです。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?