ackley14 0 Posted March 9, 2017 Share Posted March 9, 2017 Keyboard.isKeyDown(keyboard.keys.space) and other variants are always returning nil and i'm not sure why! here's my code keyboard = require("keyboard") while true do print(keyboard.isKeyDown(keyboard.keys.space)) end this returns nil over and over. no amount of button pressing changes the output for whatever reason any ideas why? Quote Link to post Share on other sites
1 Solution Molinko 43 Posted March 9, 2017 Solution Share Posted March 9, 2017 Key presses are events. You need to yield (i.e event.pull ) to catch them. Try this.. require('event').pull('key') print( require('keyboard').isKeyDown( 0x39 ) ) Quote Link to post Share on other sites
1 Gorzoid 10 Posted March 9, 2017 Share Posted March 9, 2017 This may be because you are not sleeping, if you constantly check without yielding then it can't check keys pressed, add an os.sleep call before or after the print Quote Link to post Share on other sites
Keyboard.isKeyDown(keyboard.keys.space) and other variants are always returning nil and i'm not sure why!
here's my code
keyboard = require("keyboard") while true do print(keyboard.isKeyDown(keyboard.keys.space)) end
this returns nil over and over. no amount of button pressing changes the output for whatever reason
any ideas why?
Link to post
Share on other sites