Skip to content

Commit 1c56ce0

Browse files
committed
Define a meta style for key names, render as small caps
1 parent 9f6288b commit 1c56ce0

File tree

10 files changed

+25
-16
lines changed

10 files changed

+25
-16
lines changed

01_values.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ match.
257257
Almost anything can be put between quotes, and JavaScript will make a
258258
string value out of it. But a few characters are more difficult. You
259259
can imagine how putting quotes between quotes might be hard.
260-
_Newlines_ (the characters you get when you press Enter) can be
260+
_Newlines_ (the characters you get when you press [enter]{keyname}) can be
261261
included without escaping only when the string is quoted with backticks
262262
(`` ` ``).
263263

02_program_structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ systems (including all modern web ((browser))s and Node.js) provide a
277277
`console.log` function that writes out its arguments to _some_ text
278278
output device. In browsers, the output lands in the ((JavaScript
279279
console)). This part of the browser interface is hidden by default,
280-
but most browsers open it when you press F12 or, on a Mac, command-option-I.
280+
but most browsers open it when you press F12 or, on a Mac, [command]{keyname}-[option]{keyname}-I.
281281
If that does not work, search through the menus for an item named Developer
282282
Tools or similar.
283283

15_event.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ behavior is broken.
280280

281281
Depending on the browser, some events can't be intercepted at all. On
282282
Chrome, for example, the ((keyboard)) shortcut to close the current
283-
tab (Ctrl-W or Command-W) cannot be handled by JavaScript.
283+
tab ([control]{keyname}-W or [command]{keyname}-W) cannot be handled by JavaScript.
284284

285285
## Key events
286286

@@ -321,22 +321,22 @@ longer.
321321
The example looked at the `key` property of the event object to see
322322
which key the event is about. This property holds a string that, for
323323
most keys, corresponds to the thing that pressing that key would type.
324-
For special keys like Enter, it holds a string that names the key
325-
(`"Enter"`, in this case). If you hold shift while pressing a key,
324+
For special keys like [enter]{keyname}, it holds a string that names the key
325+
(`"Enter"`, in this case). If you hold [shift]{keyname} while pressing a key,
326326
that might also influence the name of the key—`"v"` becomes `"V"`,
327-
`"1"` may become `"!"`, if that is what pressing Shift-1 produces on
327+
`"1"` may become `"!"`, if that is what pressing [shift]{keyname}-1 produces on
328328
your keyboard.
329329

330330
{{index "modifier key", "shift key", "control key", "alt key", "meta key", "command key", "ctrlKey property", "shiftKey property", "altKey property", "metaKey property"}}
331331

332-
Modifier keys such as Shift, Ctrl, Alt, and Meta (Command on Mac)
332+
Modifier keys such as [shift]{keyname}, [control]{keyname}, [alt]{keyname}, and [meta]{keyname} ([command]{keyname} on Mac)
333333
generate key events just like normal keys. But when looking for key
334334
combinations, you can also find out whether these keys are held down
335335
by looking at the `shiftKey`, `ctrlKey`, `altKey`, and `metaKey`
336336
properties of keyboard and mouse events.
337337

338338
```{lang: "text/html", focus: true}
339-
<p>Press Ctrl-Space to continue.</p>
339+
<p>Press Control-Space to continue.</p>
340340
<script>
341341
window.addEventListener("keydown", event => {
342342
if (event.key == " " && event.ctrlKey) {

18_http.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ user has focused something else.
619619
{{index "tab key", keyboard, "tabindex attribute", "a (HTML tag)"}}
620620

621621
Browsers traditionally also allow the user to move the focus
622-
through the document by pressing the Tab key. We can influence the
622+
through the document by pressing the [tab]{keyname} key. We can influence the
623623
order in which elements receive focus with the `tabindex` attribute.
624624
The following example document will let focus jump from the text input to
625625
the OK button, rather than going through the help link first:
@@ -702,10 +702,10 @@ acts both as an array-like object (accessible by number) and a ((map))
702702
</script>
703703
```
704704

705-
{{index "button (HTML tag)", "type attribute", submit, "Enter key"}}
705+
{{index "button (HTML tag)", "type attribute", submit, "enter key"}}
706706

707707
A button with a `type` attribute of `submit` will, when pressed,
708-
cause the form to be submitted. Pressing Enter when a form field is
708+
cause the form to be submitted. Pressing [enter]{keyname} when a form field is
709709
focused has the same effect.
710710

711711
{{index "submit event", "event handling", "preventDefault method", "page reload", "GET method", "POST method"}}
@@ -922,7 +922,7 @@ deselect an option.
922922

923923
This example extracts the selected values from a `multiple` select
924924
field and uses them to compose a binary number from individual bits.
925-
Hold Ctrl (or Command on a Mac) to select multiple options.
925+
Hold [control]{keyname} (or [command]{keyname} on a Mac) to select multiple options.
926926

927927
```{lang: "text/html"}
928928
<select multiple>

19_paint.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ more features as exercises.
10321032
{{index "keyboard bindings (exercise)"}}
10331033

10341034
Add ((keyboard)) shortcuts to the application. The first letter of a
1035-
tool's name selects the tool, and Ctrl-Z or Command-Z activates undo.
1035+
tool's name selects the tool, and [control]{keyname}-Z or [command]{keyname}-Z activates undo.
10361036

10371037
{{index "PixelEditor class", "tabindex attribute", "elt function", "keydown event"}}
10381038

@@ -1094,8 +1094,8 @@ if}}
10941094
{{index "keyboard bindings (exercise)", "key property", "shift key"}}
10951095

10961096
The `key` property of events for letter keys will be the lower case
1097-
letter itself, if Shift isn't being held. And we're not interested in
1098-
key events with Shift here.
1097+
letter itself, if [shift]{keyname} isn't being held. And we're not interested in
1098+
key events with [shift]{keyname} here.
10991099

11001100
{{index "keydown event"}}
11011101

20_node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ _localhost_, which would use the default port 80.
535535
When you run this script, the process just sits there and waits. When
536536
a script is listening for events—in this case, network
537537
connections—`node` will not automatically exit when it reaches the end
538-
of the script. To close it, press Ctrl-C.
538+
of the script. To close it, press {{control}}-C.
539539

540540
A real web ((server)) usually does more than the one in the example—it
541541
looks at the request's ((method)) (the `method` property) to see what

epub/style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ figure.framed img {
120120
border: 2px solid black;
121121
}
122122

123+
span.keyname { font-variant: small-caps }
124+
123125
td {
124126
vertical-align: top;
125127
}

html/css/ejs.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ figure.square-framed img {
399399
border: 4px double #666;
400400
}
401401

402+
span.keyname { font-variant: small-caps }
403+
402404
@media screen and (max-width: 500px) {
403405
figure {
404406
margin: 0;

src/render_html.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ let renderer = {
151151
return (author ? `\n\n<footer>${escape(author)}${title ? `, <cite>${escape(title)}</cite>` : ""}</footer>` : "") +
152152
"\n\n</blockquote>"
153153
},
154+
meta_keyname_open() { return "<span class=\"keyname\">" },
155+
meta_keyname_close() { return "</span>" },
154156

155157
meta_hint_open() { return "\n\n<div class=\"solution\"><div class=\"solution-text\">" },
156158
meta_hint_close() { return "\n\n</div></div>" }

src/render_latex.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ let renderer = {
161161
meta_latex_open() { raw = true; return "" },
162162
meta_latex_close() { raw = false; return "" },
163163

164+
meta_keyname_open() { return "\\textsc{" },
165+
meta_keyname_close() { return "}" },
166+
164167
link_open(token) {
165168
let href= token.attrGet("href")
166169
let maybeChapter = /^(\w+)(?:#(.*))?$/.exec(href)

0 commit comments

Comments
 (0)