t1a10: Events by Innes

Good reference to HTML Events

Events are actions detected by HTML and the browser. JavaScript can respond to these events, and this page uses a bridge to let Luau respond to them too.

1. onClick


2. onMouseOver and onMouseOut

This is BOLD

3. onDblClick

4. onMouseDown

5. onMouseUp

6. onMouseMove

Move your mouse here

7. onFocus

8. onBlur

9. onChange

10. onKeyDown

11. onKeyUp

12. onInput

Event Output

Events will appear here!

JavaScript → Luau

JavaScript event example:

document.getElementById("clickButton").addEventListener("click", function() {
    document.getElementById("eventOutput").textContent = "You clicked!";
});

Luau event-handling example:

local eventName = getEventName()
local eventValue = getEventValue()

if eventName == "click" then
    setEventOutput("You clicked!")
end

The browser detects the event in JavaScript and passes its name and value to Luau using bridge functions.


Luau Code Editor

Interact with the examples above to trigger your Luau code. Edit this code to change how events are handled, then click Run Luau to activate your changes.


Luau Console Output