localfunctionkeyboardPressed(KeyCode,event) print(KeyCode) end localfunctionkeyboardReleased(KeyCode,event) end local listener = cc.EventListenerKeyboard:create() listener:registerScriptHandler(keyboardPressed, cc.Handler.EVENT_KEYBOARD_PRESSED) listener:registerScriptHandler(keyboardReleased, cc.Handler.EVENT_KEYBOARD_RELEASED) local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener,self)