I have a button that opens a menu in our level,
In implementing the Android onKeyEvent I also
want to be able to open that menu if the user presses
the actual device menu button.
However, I need a way so that this doesn't "spam" the device button
if the user hits it on the device more than once.
what can be added to the onKeyEvent code for such a thing?
example:
1 2 3 4 5 6 7 8 9 10 11 12 | local function onKeyEvent( event ) local returnValue = true if (event.phase=="up" and event.keyName=="menu") then timer.performWithDelay(100,openMenu,1) end return returnValue end -- Add the key callback Runtime:addEventListener( "key", onKeyEvent ) |