@@ -21,9 +21,9 @@ flow than the one we have used so far.
2121
2222(((polling)))(((button)))(((real-time)))Imagine an interface where the
2323only way to find out whether a key on the keyboard is being pressed is to read the
24- current state of that key. To be able to react to key
25- presses, you would have to constantly read the key's state so that
26- you'd catch it before it gets released again. It would be dangerous to
24+ current state of that key. To be able to react to keypresses,
25+ you would have to constantly read the key's state so that
26+ you'd catch it before it's released again. It would be dangerous to
2727perform other time-intensive computations since you might miss a
2828keypress.
2929
@@ -91,7 +91,7 @@ you can't accidentally replace a handler that has already been
9191registered.
9292
9393(((removeEventListener method)))The `removeEventListener` method,
94- called with similar arguments as `addEventListener`, removes a
94+ called with arguments similar to as `addEventListener`, removes a
9595handler.
9696
9797[source,text/html]
@@ -256,8 +256,7 @@ Chrome, for example, ((keyboard)) shortcuts to close the current tab
256256
257257(((keyboard)))(((keydown event)))(((keyup event)))(((event
258258handling)))When a key on the keyboard is pressed, your browser fires a
259- `"keydown"` event. When it is released, a `"keyup"` event is
260- fired.
259+ `"keydown"` event. When it is released, a `"keyup"` event fires.
261260
262261[source,text/html]
263262[focus="yes"]
@@ -275,12 +274,12 @@ fired.
275274</script>
276275----
277276
278- (((repeating key)))Despite its name, `"keydown"` is fired not only
277+ (((repeating key)))Despite its name, `"keydown"` fires not only
279278when the key is physically pushed down. When a key is pressed and
280- held, the event is fired again every time the key _repeats_.
281- Sometimes, for example if you want to increase the acceleration of a
279+ held, the event fires again every time the key _repeats_.
280+ Sometimes— for example if you want to increase the acceleration of a
282281((game)) character when an arrow key is pressed and decrease it again
283- when the key is released, you have to be careful not to increase it
282+ when the key is released— you have to be careful not to increase it
284283again every time the key repeats or you'd end up with unintentionally
285284huge values.
286285
@@ -335,8 +334,8 @@ property)))(((keydown event)))(((keyup event)))(((keypress event)))The
335334`"keydown"` and `"keyup"` events give you information about the
336335physical key that is being pressed. But what if you are interested in
337336the actual ((text)) being typed? Getting that text from key codes is
338- awkward. Instead, there exists another event, `"keypress"`, which is
339- fired right after `"keydown"` (and repeated along with `"keydown"`
337+ awkward. Instead, there exists another event, `"keypress"`, which
338+ fires right after `"keydown"` (and repeated along with `"keydown"`
340339when the key is held) but only for keys that produce character input.
341340The `charCode` property in the event object contains a code that can
342341be interpreted as a ((Unicode)) character code. We can use the
@@ -365,21 +364,21 @@ focus, `document.body` acts as the target node of key events.
365364== Mouse clicks ==
366365
367366(((mousedown event)))(((mouseup event)))(((mouse cursor)))Pressing a
368- ((mouse button)) also causes a number of events to be fired . The
367+ ((mouse button)) also causes a number of events to fire . The
369368`"mousedown"` and `"mouseup"` events are similar to `"keydown"` and
370- `"keyup"` and are fired when the button is pressed and released.
369+ `"keyup"` and fire when the button is pressed and released.
371370These will happen on the DOM nodes that are immediately below the
372371mouse pointer when the event occurs.
373372
374- (((click event)))After the `"mouseup"` event, a `"click"` event is
375- fired on the most specific node that contained both the press and the
373+ (((click event)))After the `"mouseup"` event, a `"click"` event
374+ fires on the most specific node that contained both the press and the
376375release of the button. For example, if I press down the mouse button
377376on one paragraph and then move the pointer to another paragraph and
378377release the button, the `"click"` event will happen on the element
379378that contains both those paragraphs.
380379
381380(((dblclick event)))(((double click)))If two clicks happen close
382- together, a `"dblclick"` (double-click) event is also fired , after the
381+ together, a `"dblclick"` (double-click) event also fires , after the
383382second click event.
384383
385384(((pixel)))(((pageX property)))(((pageY property)))(((event
@@ -497,15 +496,15 @@ so the `buttonPressed` function in the example first tries `buttons`,
497496and falls back to `which` when that isn't available.
498497
499498(((mouseover event)))(((mouseout event)))Whenever the mouse pointer
500- enters or leaves a node, a `"mouseover"` or `"mouseout"` event is
501- fired . These two events can be used, among other things, to create
499+ enters or leaves a node, a `"mouseover"` or `"mouseout"` event
500+ fires . These two events can be used, among other things, to create
502501((hover effect))s, showing or styling something when the mouse is over
503502a given element.
504503
505504(((event propagation)))Unfortunately, creating such an effect is not
506505as simple as starting the effect on `"mouseover"` and ending it on
507506`"mouseout"`. When the mouse moves from a node onto one of its
508- children, `"mouseout"` is fired on the parent node, though the mouse
507+ children, `"mouseout"` fires on the parent node, though the mouse
509508did not actually leave the node's extent. To make things worse, these
510509events propagate just like other events, and thus you will also
511510receive `"mouseout"` events when the mouse leaves one of the ((child
@@ -562,7 +561,7 @@ with `"mouseover"` and `"mouseout"` events.
562561== Scroll events ==
563562
564563(((scrolling)))(((scroll event)))(((event handling)))Whenever an
565- element is scrolled, a `"scroll"` event is fired on it. This has
564+ element is scrolled, a `"scroll"` event fires on it. This has
566565various uses, such as knowing what the user is currently looking at
567566(for disabling off-screen ((animation))s or sending ((spy)) reports to
568567your evil headquarters) or showing some indication of progress (by
@@ -660,8 +659,7 @@ focus:
660659
661660ifdef::book_target[]
662661
663- The following screenshot shows the help text for the age field being
664- shown.
662+ In the following screenshot, the help text for the age field is shown.
665663
666664image::img/help-field.png[alt="Providing help when a field is focused",width="4.4cm"]
667665
@@ -674,7 +672,7 @@ browser tab or window in which the document is shown.
674672== Load event ==
675673
676674(((script (HTML tag))))(((load event)))When a page finishes loading,
677- the `"load"` event is fired on the window and the document body
675+ the `"load"` event fires on the window and the document body
678676objects. This is often used to schedule ((initialization)) actions
679677that require the whole ((document)) to have been built. Remember that
680678the content of `<script>` tags is run immediately when the tag is
@@ -689,7 +687,7 @@ focus-related events, loading events do not propagate.
689687
690688(((beforeunload event)))(((page reload)))(((preventDefault
691689method)))When a page is closed or navigated away from (for example by
692- following a link), a `"beforeunload"` event is fired . The main use of
690+ following a link), a `"beforeunload"` event fires . The main use of
693691this event is to prevent the user from accidentally losing work by
694692closing a document. Preventing the page from unloading is not, as you
695693might expect, done with the `preventDefault` method. Instead, it is
@@ -906,7 +904,7 @@ no direct control over. The `addEventListener` method is used to
906904register such a handler.
907905
908906Each event has a type (`"keydown"`, `"focus"`, and so on) that identifies
909- it. Most events are called on a specific DOM elements and then
907+ it. Most events are called on a specific DOM element and then
910908_propagate_ to that element's ancestors, allowing handlers associated
911909with those elements to handle them.
912910
@@ -999,7 +997,7 @@ want you to implement a mouse trail. Use absolutely positioned `<div>`
999997elements with a fixed size and background color (refer to the
1000998link:14_event.html#mouse_drawing[code] in the “Mouse Clicks”
1001999section for an example). Create a bunch of such elements and, when the
1002- mouse moves, display them in the wake of the mouse pointer, somehow .
1000+ mouse moves, display them in the wake of the mouse pointer.
10031001
10041002(((mousemove event)))There are various possible approaches here. You
10051003can make your solution as simple or as complex as you want. A simple
0 commit comments