Skip to content

Commit 577bae0

Browse files
committed
Integrate proofreading for Chapter 14
1 parent 8daf378 commit 577bae0

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

14_event.txt

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ flow than the one we have used so far.
2121

2222
(((polling)))(((button)))(((real-time)))Imagine an interface where the
2323
only 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
2727
perform other time-intensive computations since you might miss a
2828
keypress.
2929

@@ -91,7 +91,7 @@ you can't accidentally replace a handler that has already been
9191
registered.
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
9595
handler.
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
258258
handling)))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
279278
when 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+
Sometimesfor 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 releasedyou have to be careful not to increase it
284283
again every time the key repeats or you'd end up with unintentionally
285284
huge values.
286285

@@ -335,8 +334,8 @@ property)))(((keydown event)))(((keyup event)))(((keypress event)))The
335334
`"keydown"` and `"keyup"` events give you information about the
336335
physical key that is being pressed. But what if you are interested in
337336
the 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"`
340339
when the key is held) but only for keys that produce character input.
341340
The `charCode` property in the event object contains a code that can
342341
be 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.
371370
These will happen on the DOM nodes that are immediately below the
372371
mouse 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
376375
release of the button. For example, if I press down the mouse button
377376
on one paragraph and then move the pointer to another paragraph and
378377
release the button, the `"click"` event will happen on the element
379378
that 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
383382
second click event.
384383

385384
(((pixel)))(((pageX property)))(((pageY property)))(((event
@@ -497,15 +496,15 @@ so the `buttonPressed` function in the example first tries `buttons`,
497496
and 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
503502
a given element.
504503

505504
(((event propagation)))Unfortunately, creating such an effect is not
506505
as 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
509508
did not actually leave the node's extent. To make things worse, these
510509
events propagate just like other events, and thus you will also
511510
receive `"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
566565
various uses, such as knowing what the user is currently looking at
567566
(for disabling off-screen ((animation))s or sending ((spy)) reports to
568567
your evil headquarters) or showing some indication of progress (by
@@ -660,8 +659,7 @@ focus:
660659

661660
ifdef::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

666664
image::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
678676
objects. This is often used to schedule ((initialization)) actions
679677
that require the whole ((document)) to have been built. Remember that
680678
the 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
691689
method)))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
693691
this event is to prevent the user from accidentally losing work by
694692
closing a document. Preventing the page from unloading is not, as you
695693
might expect, done with the `preventDefault` method. Instead, it is
@@ -906,7 +904,7 @@ no direct control over. The `addEventListener` method is used to
906904
register such a handler.
907905

908906
Each 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
911909
with those elements to handle them.
912910

@@ -999,7 +997,7 @@ want you to implement a mouse trail. Use absolutely positioned `<div>`
999997
elements with a fixed size and background color (refer to the
1000998
link:14_event.html#mouse_drawing[code] in the “Mouse Clicks”
1001999
section 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
10051003
can make your solution as simple or as complex as you want. A simple

0 commit comments

Comments
 (0)