Gotchas

Example

-- Called when a key event has been received
local function onKeyEvent( event )
-- Vibrate the gamepad if its 'A' button was pressed
if ( event.keyName == "buttonA" ) and ( event.phase == "down" ) then
if event.device and event.device.canVibrate then
event.device:vibrate()
end
end
end
-- Set up the above function to receive key events
Runtime:addEventListener( "key", onKeyEvent )