An event is an attribute whose value is an action, a call or a block. Some hand the handler something: a field's value, a key's name, where the pointer is. Every one the language has is here, with what it hands over.
Presses and fields
press, dblclick, contextmenupress is a click, a tap, or Enter and Space on a button. contextmenu is the other mouse button or a long press, and takes the browser's menu's place.
Press, double-press, or right-press here
press0
dblclick0
contextmenu0
Nothing yet.
input, change, submit, focus, blurinput and change append the field's value: text, a checkbox's bool, a number from number and range. submit on a field is Enter.
Nothing yet: click into the field.
key, keyupBoth append the key's name. On anything but a field key is for shortcuts: it hears keys while the keyboard is inside it.
Click here, then press keys↑ and ↓ are a shortcut: 0
No key yet.
The pointer
A mouse, a finger or a pen: one set of events for all three.
pointerdown, pointerup, pointermove, pointerenter, pointerleavedown, move and up append {x, y, width, height}: where the pointer is from the element's corner, and the element's size.
Move the pointer over this pad, and press
x0
y0
width0
height0
last eventnone yet
outside
up
A dragAn element with both pointerdown and pointermove keeps the pointer for the whole drag, even when it leaves the element.
x60
y60
dragged0 px
let go
Every press ends once: 0 by pointerup, 0 by pointercancel.
swipe=One finger, a mouse or a pen drawn along the card: it follows, and a flick or more than half its width throws it. tx is where the card stood when the swipe began, in the middle of a transition too, so a card caught as it slides stays under the finger. The button inside it is still a button; the page still scrolls up and down over it.
Card 1Draw me to one side, or flick me.
x = 0
thrown0
x0
start, end and cancel are written here (move is left out).
wheelIt appends where the pointer is and {dx, dy, pinch}, and the page does not scroll. pinch is true for a trackpad pinch (or the wheel with Ctrl).
Turn the wheel here: it spins. Pinch: it grows.
dx0
dy0
pinchfalse
events0
Told by the element
Things that happen to an element rather than to the pointer.
scrollEach time the element scrolls. It hands over nothing: read the element through its ref.
1Row 1
2Row 2
3Row 3
4Row 4
5Row 5
6Row 6
7Row 7
8Row 8
9Row 9
10Row 10
11Row 11
12Row 12
13Row 13
14Row 14
15Row 15
16Row 16
17Row 17
18Row 18
19Row 19
20Row 20
scrollTop0
of the way0%
scroll events0
dropFiles let go over the element: the handler runs once for each, with {name, data: bytes}.
Drag files from your desktop and let go here
No file yet. Nothing is uploaded: the page only reads them.
resizedThe element's own size changing: told once it is on the page, then on every change, with {width, height}. Drag the corner of the box.
0 × 0
width0
height0
told0 times
It also changes when the window does: the box is never wider than its card.
contentsWhat is inside the element changing: something added, removed or reworded.
oak
ash
contents ran0 times
The element itself
ref= and el.*state box: element? = none, then ref=box fills it. The reads give numbers; el.scrollTo, el.focus and el.blur act. Before the element is on the page the reads give 0 and the rest do nothing.