diff --git a/cocos/2d/CCEventListenerKeyboard.cpp b/cocos/2d/CCEventListenerKeyboard.cpp index c947a43e36..77ce94d705 100644 --- a/cocos/2d/CCEventListenerKeyboard.cpp +++ b/cocos/2d/CCEventListenerKeyboard.cpp @@ -31,7 +31,11 @@ NS_CC_BEGIN bool EventListenerKeyboard::checkAvailable() { - CCASSERT(onKeyPressed && onKeyReleased, ""); + if (onKeyPressed == nullptr && onKeyReleased == nullptr) + { + CCASSERT(false, "Invalid EventListenerKeyboard!"); + return false; + } return true; }