Manages events, like keypresses. Use this skill when working with event management, event callbacks, event pumping, or any event-related operations in LÖVE games.
Manages events, like keypresses. Use this skill when working with event management, event callbacks, event pumping, or any event-related operations in LÖVE games.
love.event.clear(): Clears the event queue.love.event.poll() -> i: function: Returns an iterator for messages in the event queue.love.event.pump(): Pump events into the event queue. This is a low-level function, and is usually not called by the user, but by love.run. Note that this does need to be called for any OS to think you're still running, and if you want to handle OS-generated events at all (think callbacks).love.event.push(n: Event, a: Variant, b: Variant, c: Variant, d: Variant, e: Variant, f: Variant, ...: Variant): Adds an event to the event queue. From 0.10.0 onwards, you may pass an arbitrary amount of arguments with this function, though the default callbacks don't ever use more than six.love.event.quit - Adds the quit event to the queue. The quit event is a signal for the event handler to close LÖVE. It's possible to abort the exit process with the love.quit callback.love.event.quit(exitstatus: number): No descriptionlove.event.quit('restart': string): Restarts the game without relaunching the executable. This cleanly shuts down the main Lua state instance and creates a brand new one.love.event.wait() -> n: Event, a: Variant, b: Variant, c: Variant, d: Variant, e: Variant, f: Variant, ...: Variant: Like love.event.poll(), but blocks until there is an event in the queue.Event: Arguments to love.event.push() and the like. Since 0.8.0, event names are no longer abbreviated.focus: Window focus gained or lostjoystickpressed: Joystick pressedjoystickreleased: Joystick releasedkeypressed: Key pressedkeyreleased: Key releasedmousepressed: Mouse pressedmousereleased: Mouse releasedquit: Quitresize: Window size changed by the uservisible: Window is minimized or un-minimized by the usermousefocus: Window mouse focus gained or lostthreaderror: A Lua error has occurred in a threadjoystickadded: Joystick connectedjoystickremoved: Joystick disconnectedjoystickaxis: Joystick axis motionjoystickhat: Joystick hat pressedgamepadpressed: Joystick's virtual gamepad button pressedgamepadreleased: Joystick's virtual gamepad button releasedgamepadaxis: Joystick's virtual gamepad axis movedtextinput: User entered textmousemoved: Mouse position changedlowmemory: Running out of memory on mobile devices systemtextedited: Candidate text for an IME changedwheelmoved: Mouse wheel movedtouchpressed: Touch screen touchedtouchreleased: Touch screen stop touchingtouchmoved: Touch press moved inside touch screendirectorydropped: Directory is dragged and dropped onto the windowfiledropped: File is dragged and dropped onto the window.jp: Joystick pressedjr: Joystick releasedkp: Key pressedkr: Key releasedmp: Mouse pressedmr: Mouse releasedq: Quitf: Window focus gained or lost-- Pump and handle events manually
function love.update(dt)
love.event.pump()
for name, a, b, c, d, e, f in love.event.poll() do
if name == "quit" then
if not love.quit or not love.quit() then
return a or 0
end
end
-- Handle other events
end
end
-- Custom quit handler
function love.quit()
-- Save game state before quitting
saveGameState()
return false -- Allow normal quit process
end