-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
742 lines (725 loc) · 48.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>System Keyboard Lock </title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="WD" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="styles.css" rel="stylesheet" type="text/css">
<link href="https://www.w3.org/StyleSheets/TR/2016/W3C-WD" rel="stylesheet" type="text/css">
<meta content="Bikeshed version 6a4f8be68430b11c876cd3230aa3d768e5c074a3" name="generator">
<style>/* style-md-lists */
/* This is a weird hack for me not yet following the commonmark spec
regarding paragraph and lists. */
[data-md] > :first-child {
margin-top: 0;
}
[data-md] > :last-child {
margin-bottom: 0;
}</style>
<style>/* style-selflinks */
.heading, .issue, .note, .example, li, dt {
position: relative;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
li > a.self-link {
left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: gray;
color: white;
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: black;
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }</style>
<style>/* style-counters */
body {
counter-reset: example figure issue;
}
.issue {
counter-increment: issue;
}
.issue:not(.no-marker)::before {
content: "Issue " counter(issue);
}
.example {
counter-increment: example;
}
.example:not(.no-marker)::before {
content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
content: "Invalid Example" counter(example);
}
figcaption {
counter-increment: figure;
}
figcaption:not(.no-marker)::before {
content: "Figure " counter(figure) " ";
}</style>
<style>/* style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: #005a9c;
font-size: inherit;
font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
content: "‘";
}
.css::after, .property::after, .descriptor::after {
content: "’";
}
.property, .descriptor {
/* Don't wrap property and descriptor names */
white-space: nowrap;
}
.type { /* CSS value <type> */
font-style: italic;
}
pre .property::before, pre .property::after {
content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
content: "’";
}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
content: "";
}
[data-link-type=element],
[data-link-type=element-attr] {
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
[data-link-type=biblio] {
white-space: pre;
}</style>
<style>/* style-dfn-panel */
.dfn-panel {
position: absolute;
z-index: 35;
height: auto;
width: -webkit-fit-content;
width: fit-content;
max-width: 300px;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-syntax-highlighting */
pre.idl.highlight { color: #708090; }
.highlight:not(.idl) { background: hsl(24, 20%, 95%); }
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
.highlight .c { color: #708090 } /* Comment */
.highlight .k { color: #990055 } /* Keyword */
.highlight .l { color: #000000 } /* Literal */
.highlight .n { color: #0077aa } /* Name */
.highlight .o { color: #999999 } /* Operator */
.highlight .p { color: #999999 } /* Punctuation */
.highlight .cm { color: #708090 } /* Comment.Multiline */
.highlight .cp { color: #708090 } /* Comment.Preproc */
.highlight .c1 { color: #708090 } /* Comment.Single */
.highlight .cs { color: #708090 } /* Comment.Special */
.highlight .kc { color: #990055 } /* Keyword.Constant */
.highlight .kd { color: #990055 } /* Keyword.Declaration */
.highlight .kn { color: #990055 } /* Keyword.Namespace */
.highlight .kp { color: #990055 } /* Keyword.Pseudo */
.highlight .kr { color: #990055 } /* Keyword.Reserved */
.highlight .kt { color: #990055 } /* Keyword.Type */
.highlight .ld { color: #000000 } /* Literal.Date */
.highlight .m { color: #000000 } /* Literal.Number */
.highlight .s { color: #a67f59 } /* Literal.String */
.highlight .na { color: #0077aa } /* Name.Attribute */
.highlight .nc { color: #0077aa } /* Name.Class */
.highlight .no { color: #0077aa } /* Name.Constant */
.highlight .nd { color: #0077aa } /* Name.Decorator */
.highlight .ni { color: #0077aa } /* Name.Entity */
.highlight .ne { color: #0077aa } /* Name.Exception */
.highlight .nf { color: #0077aa } /* Name.Function */
.highlight .nl { color: #0077aa } /* Name.Label */
.highlight .nn { color: #0077aa } /* Name.Namespace */
.highlight .py { color: #0077aa } /* Name.Property */
.highlight .nt { color: #669900 } /* Name.Tag */
.highlight .nv { color: #222222 } /* Name.Variable */
.highlight .ow { color: #999999 } /* Operator.Word */
.highlight .mb { color: #000000 } /* Literal.Number.Bin */
.highlight .mf { color: #000000 } /* Literal.Number.Float */
.highlight .mh { color: #000000 } /* Literal.Number.Hex */
.highlight .mi { color: #000000 } /* Literal.Number.Integer */
.highlight .mo { color: #000000 } /* Literal.Number.Oct */
.highlight .sb { color: #a67f59 } /* Literal.String.Backtick */
.highlight .sc { color: #a67f59 } /* Literal.String.Char */
.highlight .sd { color: #a67f59 } /* Literal.String.Doc */
.highlight .s2 { color: #a67f59 } /* Literal.String.Double */
.highlight .se { color: #a67f59 } /* Literal.String.Escape */
.highlight .sh { color: #a67f59 } /* Literal.String.Heredoc */
.highlight .si { color: #a67f59 } /* Literal.String.Interpol */
.highlight .sx { color: #a67f59 } /* Literal.String.Other */
.highlight .sr { color: #a67f59 } /* Literal.String.Regex */
.highlight .s1 { color: #a67f59 } /* Literal.String.Single */
.highlight .ss { color: #a67f59 } /* Literal.String.Symbol */
.highlight .vc { color: #0077aa } /* Name.Variable.Class */
.highlight .vg { color: #0077aa } /* Name.Variable.Global */
.highlight .vi { color: #0077aa } /* Name.Variable.Instance */
.highlight .il { color: #000000 } /* Literal.Number.Integer.Long */
</style>
<body class="h-entry">
<div class="head">
<header>
<p data-fill-with="logo"><a href="http://www.w3.org/"><img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"></a></p>
<h1>System Keyboard Lock</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Working Draft, <time class="dt-updated" datetime="2016-12-13">13 December 2016</time></span></h2>
</header>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://www.w3.org/TR/2016/WD-systemkeylock-20161213/">https://www.w3.org/TR/2016/WD-systemkeylock-20161213/</a>
<dt>Latest published version:
<dd><a href="http://www.w3.org/TR/systemkeylock/">http://www.w3.org/TR/systemkeylock/</a>
<dt>Editor's Draft:
<dd><a href="https://github.com/w3c/systemkeylock/">https://github.com/w3c/systemkeylock/</a>
<dt>Previous Versions:
<dd><a href="" rel="previous"></a>
<dd><a href="<none>" rel="previous"><none></a>
<dt>Issue Tracking:
<dd><a href="https://github.com/garykac/system-keyboard-lock/issues/">GitHub</a>
<dd><a href="#issues-index">Inline In Spec</a>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><span class="p-name fn"></span>
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:[email protected]">Gary Kacmarcik</a> (<span class="p-org org">Google</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:[email protected]">Jamie Walch</a> (<span class="p-org org">Google</span>)
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2016 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply. </p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This specification defines an API that allows websites to
capture keys that are normally reserved by the underlying host
operating system. It is intended to be used by web
applications that provide a fullscreen immersive experience
(like games or remote access apps).</p>
</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p> <em>This section describes the status of this document at the time of its publication. Other
documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision of this
technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical
reports index</a> at http://www.w3.org/TR/.</em> </p>
<p> The management and production of this document follows a relatively complex setup. Details are
provided as part of the introduction. </p>
<p> This document was published by the <a href="https://www.w3.org/WebPlatform/WG/">Web Platform Working Group</a> as a Working Draft.
Feedback and comments on this specification are welcome. Please use <a href="https://github.com/w3c/systemkeylock/issues">Github issues</a> Historical discussions can be found in the <a href="http://lists.w3.org/Archives/Public/public-webapps/">[email protected] archives</a>. </p>
<p> Publication as a Working Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership. This is a draft document and may
be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite
this document as other than work in progress. </p>
<p> This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/40318/status" rel="disclosure">public list of any
patent disclosures</a> made in connection with the deliverables of the group; that page also
includes instructions for disclosing a patent. An individual who has actual knowledge of a
patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. </p>
<p> This document is governed by the <a href="http://www.w3.org/2015/Process-20150901/" id="w3c_process_revision">1 September 2015 <abbr title="World Wide Web Consortium">W3C</abbr> Process Document</a>. </p>
<p></p>
</div>
<div data-fill-with="at-risk"></div>
<nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li><a href="#introduction"><span class="secno">1</span> <span class="content">Introduction</span></a>
<li>
<a href="#API"><span class="secno">2</span> <span class="content">Activating and Deactivating System Keyboard Lock</span></a>
<ol class="toc">
<li><a href="#requestSystemKeyboardLock"><span class="secno">2.1</span> <span class="content">requestSystemKeyboardLock</span></a>
<li><a href="#cancelSystemKeyboardLock"><span class="secno">2.2</span> <span class="content">cancelSystemKeyboardLock</span></a>
</ol>
<li>
<a href="#handling-events"><span class="secno">3</span> <span class="content">Handling Keyboard Key Presses</span></a>
<ol class="toc">
<li>
<a href="#key-press-handler"><span class="secno">3.1</span> <span class="content">System Key Press Handler</span></a>
<ol class="toc">
<li><a href="#registering"><span class="secno">3.1.1</span> <span class="content">Registering</span></a>
<li><a href="#unregistering"><span class="secno">3.1.2</span> <span class="content">Unregistering</span></a>
</ol>
<li><a href="#handling-keyboard-events"><span class="secno">3.2</span> <span class="content">Handling Keyboard Events</span></a>
</ol>
<li><a href="#fullscreen-considerations"><span class="secno">4</span> <span class="content">Fullscreen Considerations</span></a>
<li><a href="#mobile"><span class="secno">5</span> <span class="content">Mobile Device Considerations</span></a>
<li><a href="#security"><span class="secno">6</span> <span class="content">Security Considerations</span></a>
<li><a href="#privacy"><span class="secno">7</span> <span class="content">Privacy Considerations</span></a>
<li><a href="#acknowledgements-contributors"><span class="secno">8</span> <span class="content">Acknowledgements</span></a>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ol>
<li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
</ol>
</nav>
<main>
<h2 class="heading settled" data-level="1" id="introduction"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#introduction"></a></h2>
<p>Richly interactive web sites, games and remote
desktop/application streaming experiences want to provide an
immersive, full screen experience. To accomplish this, sites
need access to special keys and keyboard shortcuts while they
are in full screen mode so that they can be used for
navigation, menus or gaming functionality. Some examples of
the keys that may be required are Escape, Alt+Tab, Cmd+`, and
Ctrl+N.</p>
<p>By default, these keys are not available to the web application because
they are captured by the browser or the underlying operating
system. The System Keyboard Lock API enables websites to capture and use
all available keys allowed by the OS.</p>
<h2 class="heading settled" data-level="2" id="API"><span class="secno">2. </span><span class="content">Activating and Deactivating System Keyboard Lock</span><a class="self-link" href="#API"></a></h2>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a> {
[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>] <span class="kt">void</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Navigator" data-dfn-type="method" data-export="" data-lt="requestSystemKeyboardLock(keyCodes)|requestSystemKeyboardLock()" id="dom-navigator-requestsystemkeyboardlock">requestSystemKeyboardLock</dfn>(<span class="kt">optional</span> <span class="kt">sequence</span><<span class="kt">DOMString</span>> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Navigator/requestSystemKeyboardLock(keyCodes), Navigator/requestSystemKeyboardLock()" data-dfn-type="argument" data-export="" id="dom-navigator-requestsystemkeyboardlock-keycodes-keycodes">keyCodes</dfn>);
[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>] <span class="kt">void</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Navigator" data-dfn-type="method" data-export="" data-lt="cancelSystemKeyboardLock()" id="dom-navigator-cancelsystemkeyboardlock">cancelSystemKeyboardLock</dfn>();
};
</pre>
<p>The navigator has <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="enable-keyboard-lock">enable keyboard lock</dfn>, which is a
boolean that is set to true when System Keyboard Lock is enabled.
By default, this is set to false.</p>
<p>The navigator has <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="reserved-key-codes">reserved key codes</dfn>, which is a
sequence of DOMStrings, each of which is a <a data-link-type="dfn" href="http://www.w3.org/TR/uievents-code/#valid-keyboardevent-code">valid KeyboardEvent code</a> as defined in <a data-link-type="biblio" href="#biblio-uievents-code">[UIEvents-Code]</a>.
By default this sequence is empty (which would capture all keys
if <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-1">enable keyboard lock</a> was enabled).</p>
<h3 class="heading settled" data-level="2.1" id="requestSystemKeyboardLock"><span class="secno">2.1. </span><span class="content">requestSystemKeyboardLock</span><a class="self-link" href="#requestSystemKeyboardLock"></a></h3>
<p>When <code class="idl"><a data-link-type="idl" href="#dom-navigator-requestsystemkeyboardlock" id="ref-for-dom-navigator-requestsystemkeyboardlock-1">requestSystemKeyboardLock()</a></code> is called, the user agent must
run the following steps:</p>
<ol>
<li data-md="">
<p>Reset <a data-link-type="dfn" href="#reserved-key-codes" id="ref-for-reserved-key-codes-1">reserved key codes</a> to be an empty sequence.</p>
<li data-md="">
<p>If the optional <code class="idl"><a data-link-type="idl" href="#dom-navigator-requestsystemkeyboardlock-keycodes-keycodes" id="ref-for-dom-navigator-requestsystemkeyboardlock-keycodes-keycodes-1">keyCodes</a></code> argument is present, run the
following substeps:</p>
<ol>
<li data-md="">
<p>Copy the values from <code class="idl"><a data-link-type="idl" href="#dom-navigator-requestsystemkeyboardlock-keycodes-keycodes" id="ref-for-dom-navigator-requestsystemkeyboardlock-keycodes-keycodes-2">keyCodes</a></code> into <a data-link-type="dfn" href="#reserved-key-codes" id="ref-for-reserved-key-codes-2">reserved key codes</a>,
removing any entries which are not <a data-link-type="dfn" href="http://www.w3.org/TR/uievents-code/#valid-keyboardevent-code">valid KeyboardEvent codes</a> or duplicate.</p>
</ol>
<li data-md="">
<p>If <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-2">enable keyboard lock</a> is currently false, run the following
substeps:</p>
<ol>
<li data-md="">
<p><a data-link-type="dfn" href="#register-a-system-key-press-handler" id="ref-for-register-a-system-key-press-handler-1">Register a system key press handler</a>.</p>
<li data-md="">
<p>Set <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-3">enable keyboard lock</a> to be true.</p>
</ol>
</ol>
<h3 class="heading settled" data-level="2.2" id="cancelSystemKeyboardLock"><span class="secno">2.2. </span><span class="content">cancelSystemKeyboardLock</span><a class="self-link" href="#cancelSystemKeyboardLock"></a></h3>
<p>When <code class="idl"><a data-link-type="idl" href="#dom-navigator-cancelsystemkeyboardlock" id="ref-for-dom-navigator-cancelsystemkeyboardlock-1">cancelSystemKeyboardLock()</a></code> is called, the user agent must
run the following steps:</p>
<ol>
<li data-md="">
<p>If <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-4">enable keyboard lock</a> is true, then run the following substeps:</p>
<ol>
<li data-md="">
<p><a data-link-type="dfn" href="#unregister-the-system-key-press-handler" id="ref-for-unregister-the-system-key-press-handler-1">Unregister the system key press handler</a>.</p>
<li data-md="">
<p>Set <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-5">enable keyboard lock</a> to be false.</p>
<li data-md="">
<p>Reset <a data-link-type="dfn" href="#reserved-key-codes" id="ref-for-reserved-key-codes-3">reserved key codes</a> to be an empty sequence.</p>
</ol>
</ol>
<h2 class="heading settled" data-level="3" id="handling-events"><span class="secno">3. </span><span class="content">Handling Keyboard Key Presses</span><a class="self-link" href="#handling-events"></a></h2>
<h3 class="heading settled" data-level="3.1" id="key-press-handler"><span class="secno">3.1. </span><span class="content">System Key Press Handler</span><a class="self-link" href="#key-press-handler"></a></h3>
A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="system-key-press-handler">system key press handler</dfn> is an platform-specific handler
that can be used to filter keys at the platform level. Since
System Keyboard Lock feature is intended to provide access to key
presses that are not normally made available to the browser (for
example, Cmd/Alt-Tab), most platforms will require a special handler
to be set up.
<p>The <a data-link-type="dfn" href="#system-key-press-handler" id="ref-for-system-key-press-handler-1">system key press handler</a> must have the following properties:</p>
<ul>
<li data-md="">
<p>It must process key presses before any user agent keyboard shortcuts
are handled.</p>
<li data-md="">
<p>Wherever possible, it should process key presses before any system
keyboard shortcuts are processed.</p>
</ul>
<h4 class="heading settled" data-level="3.1.1" id="registering"><span class="secno">3.1.1. </span><span class="content">Registering</span><a class="self-link" href="#registering"></a></h4>
<p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="register-a-system-key-press-handler">register a system key press handler</dfn>, the user agent
will need to follow the platform-specific steps to add a low-level
hook that will be called whenever the platform begins to process a
new key press.</p>
<p>The exact process for adding a <a data-link-type="dfn" href="#system-key-press-handler" id="ref-for-system-key-press-handler-2">system key press handler</a> varies
from platform to platform. For examples of how to register a
low-level hook to process key presses on common platforms, see <a data-link-type="biblio" href="#biblio-lowlevelkeyboardproc">[LowLevelKeyboardProc]</a> for Windows, <a data-link-type="biblio" href="#biblio-quartzeventservices">[QuartzEventServices]</a> for
Mac OS X and <a data-link-type="biblio" href="#biblio-grabkeyboard">[GrabKeyboard]</a> for X Windows.</p>
<p class="note" role="note">Note: If the user agent already has a key press handler registered
for another purpose, then it can optionally extend that handler to
support the System Keyboard Lock feature (assuming it meets the
requirements mentioned above).</p>
<h4 class="heading settled" data-level="3.1.2" id="unregistering"><span class="secno">3.1.2. </span><span class="content">Unregistering</span><a class="self-link" href="#unregistering"></a></h4>
<p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="unregister-the-system-key-press-handler">unregister the system key press handler</dfn>, the user
agent will need to follow the platform-specific steps to remove the
(previously added) low-level hook for processing new key press.</p>
<p>As with registering system key press handlers, the process for
unregistering system key press handlers is also platform-specific.
See the references listed in <a href="#registering">§3.1.1 Registering</a> for more details and
examples.</p>
<h3 class="heading settled" data-level="3.2" id="handling-keyboard-events"><span class="secno">3.2. </span><span class="content">Handling Keyboard Events</span><a class="self-link" href="#handling-keyboard-events"></a></h3>
<p>In response to the user pressing a key, if a <a data-link-type="dfn" href="#system-key-press-handler" id="ref-for-system-key-press-handler-3">system key press handler</a> has been <a data-link-type="dfn" href="#register-a-system-key-press-handler" id="ref-for-register-a-system-key-press-handler-2">registered</a>,
it should run the following steps:</p>
<ol>
<li data-md="">
<p>Let <var>isJsFullscreen</var> be set to true if the user agent is currently in
fullscreen mode that was initiated by Element.requestFullscreen()
(see <a data-link-type="biblio" href="#biblio-fullscreen">[Fullscreen]</a>).</p>
<p class="note" role="note">Note: This can be determined by adding a tracking variable in the
requestFullscreen() call or by checking to see if
Document.fullscreenElement is non-null.</p>
<li data-md="">
<p>Let <var>hasFocus</var> be set to true if the current fullscreen document or
element has input focus.</p>
<p class="note" role="note">Note: The fullscreen element would not have focus, for example, if
there was a system dialog being displayed with focus.</p>
<li data-md="">
<p>If <var>isJsFullscreen</var>, <var>hasFocus</var> and <a data-link-type="dfn" href="#enable-keyboard-lock" id="ref-for-enable-keyboard-lock-6">enable keyboard lock</a> are all set
to true, then run the following substeps:</p>
<ol>
<li data-md="">
<p>Let <var>keyEvent</var> be the key event for the new key press.</p>
<li data-md="">
<p>Let <var>code</var> be the value of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/uievents/#dom-keyboardevent-code">code</a></code> attribute of <var>keyEvent</var>.</p>
<li data-md="">
<p>If <a data-link-type="dfn" href="#reserved-key-codes" id="ref-for-reserved-key-codes-4">reserved key codes</a> is empty or if <var>code</var> is listed in <a data-link-type="dfn" href="#reserved-key-codes" id="ref-for-reserved-key-codes-5">reserved key codes</a>, then run the following substeps:</p>
<ol>
<li data-md="">
<p>If <var>code</var> is equal to "Escape", then run the following
substeps:</p>
<ol>
<li data-md="">
<p>Optionally overlay a message on the screen telling the
user that they can Hold the Escape key to exit from
fullscreen.</p>
<li data-md="">
<p>If the key is held for 2 seconds, then exit from the
keyboard handler and pass the key on to the user agent
for normal processing (which will exit fullscreen).</p>
</ol>
<li data-md="">
<p>Dispatch <var>keyEvent</var> to the fullsceen document or element.</p>
</ol>
<li data-md="">
<p>Else, handle the key event as it normally would be handled,
either by dispatching a key event or performing the
usual keyboard shortcut action.</p>
</ol>
</ol>
<p class="note" role="note">Note: It is not required that a conforming implementation be able to
override the OS default behaviour for every key combination.
Specifically, most platforms have a “secure attention sequence” (e.g.,
Ctrl-Alt-Del on Windows) that applications cannot override; this
specification does not supersede that.</p>
<h2 class="heading settled" data-level="4" id="fullscreen-considerations"><span class="secno">4. </span><span class="content">Fullscreen Considerations</span><a class="self-link" href="#fullscreen-considerations"></a></h2>
<p>There are two different types of fullscreen available in modern user agents:
JavaScript-initiated fullscreen (via the <a data-link-type="biblio" href="#biblio-fullscreen">[Fullscreen]</a> API) and
user-initiated fullscreen (when the user enters fullscreen using a keyboard
shortcut). The user-initiated fullscreen is often referred to as "F11"
fullscreen since that is a common key shortcut used to enter and exit
fullscreen mode.</p>
<p>F11 fullscreen and JavaScript (JS) fullscreen do not behave the same way.
When a user enters F11 fullscreen, they can only exit it via the same
keyboard shortcut that they used to enter it -- the exitFullscreen()
function will not work in this case. In addition, fullscreen events that are
normally fired for JS fullscreen are not sent for F11 fullscreen.</p>
<p>Because of these differences (and because there is no standard shortcut
for F11 fullscreen), the System Keyboard Lock API is only valid when the
a JavaScript-initiated fullscreen is active. During F11 fullscreen, no
System Keyboard Lock processing of keyboard events will take place.</p>
<h2 class="heading settled" data-level="5" id="mobile"><span class="secno">5. </span><span class="content">Mobile Device Considerations</span><a class="self-link" href="#mobile"></a></h2>
<p class="issue" id="issue-72c48aba"><a class="self-link" href="#issue-72c48aba"></a> What level of support do we need on mobile? Is it enough to say that
it’s a keyboard-focused API and mobile devices typically don’t have
keyboards? What does Chrome do if you activate full-screen on a mobile
web site and hit Escape from an attached keyboard? It seems like that should
also be supported.</p>
<h2 class="heading settled" data-level="6" id="security"><span class="secno">6. </span><span class="content">Security Considerations</span><a class="self-link" href="#security"></a></h2>
<p class="issue" id="issue-39c02e2a"><a class="self-link" href="#issue-39c02e2a"></a> How does this proposal prevent malicious sites from taking all
key events and preventing the user from escaping?</p>
<p class="issue" id="issue-f0dcdf2b"><a class="self-link" href="#issue-f0dcdf2b"></a> How could this be used (alone or in conjunction with
other APIs) to give the user a bad experience?</p>
<h2 class="heading settled" data-level="7" id="privacy"><span class="secno">7. </span><span class="content">Privacy Considerations</span><a class="self-link" href="#privacy"></a></h2>
<p>Not applicable. This API does not use or reveal any personal information
about the current user.</p>
<h2 class="heading settled" data-level="8" id="acknowledgements-contributors"><span class="secno">8. </span><span class="content">Acknowledgements</span><a class="self-link" href="#acknowledgements-contributors"></a></h2>
<p>Thanks to the following people for the discussions that lead
to the creation of this proposal:</p>
<p>Jon Dahlke (Google)</p>
</main>
<script src="https://www.w3.org/scripts/TR/2016/fixup.js"></script>
<h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2>
<h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3>
<ul class="index">
<li><a href="#dom-navigator-cancelsystemkeyboardlock">cancelSystemKeyboardLock()</a><span>, in §2</span>
<li><a href="#enable-keyboard-lock">enable keyboard lock</a><span>, in §2</span>
<li><a href="#register-a-system-key-press-handler">register a system key press handler</a><span>, in §3.1.1</span>
<li><a href="#dom-navigator-requestsystemkeyboardlock">requestSystemKeyboardLock()</a><span>, in §2</span>
<li><a href="#dom-navigator-requestsystemkeyboardlock">requestSystemKeyboardLock(keyCodes)</a><span>, in §2</span>
<li><a href="#reserved-key-codes">reserved key codes</a><span>, in §2</span>
<li><a href="#system-key-press-handler">system key press handler</a><span>, in §3.1</span>
<li><a href="#unregister-the-system-key-press-handler">unregister the system key press handler</a><span>, in §3.1.2</span>
</ul>
<h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
<ul class="index">
<li>
<a data-link-type="biblio">[HTML]</a> defines the following terms:
<ul>
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a>
</ul>
<li>
<a data-link-type="biblio">[uievents]</a> defines the following terms:
<ul>
<li><a href="https://www.w3.org/TR/uievents/#dom-keyboardevent-code">code</a>
</ul>
<li>
<a data-link-type="biblio">[UIEvents-Code]</a> defines the following terms:
<ul>
<li><a href="http://www.w3.org/TR/uievents-code/#valid-keyboardevent-code">valid keyboardevent code</a>
</ul>
<li>
<a data-link-type="biblio">[WebIDL]</a> defines the following terms:
<ul>
<li><a href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>
</ul>
</ul>
<h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
<h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
<dl>
<dt id="biblio-html">[HTML]
<dd>Ian Hickson. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
<dt id="biblio-uievents">[UIEVENTS]
<dd>Gary Kacmarcik; Travis Leithead. <a href="https://www.w3.org/TR/uievents/">UI Events</a>. 4 August 2016. WD. URL: <a href="https://www.w3.org/TR/uievents/">https://www.w3.org/TR/uievents/</a>
<dt id="biblio-uievents-code">[UIEvents-Code]
<dd>Gary Kacmarcik; Travis Leithead. <a href="https://www.w3.org/TR/uievents-code/">UI Events KeyboardEvent code Values</a>. 24 October 2016. WD. URL: <a href="https://www.w3.org/TR/uievents-code/">https://www.w3.org/TR/uievents-code/</a>
<dt id="biblio-webidl">[WebIDL]
<dd>Cameron McCormack; Boris Zbarsky; Tobie Langel. <a href="https://www.w3.org/TR/WebIDL-1/">Web IDL</a>. 15 September 2016. WD. URL: <a href="https://www.w3.org/TR/WebIDL-1/">https://www.w3.org/TR/WebIDL-1/</a>
</dl>
<h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3>
<dl>
<dt id="biblio-fullscreen">[Fullscreen]
<dd>Anne van Kesteren. <a href="https://fullscreen.spec.whatwg.org/">Fullscreen API Standard</a>. Living Standard. URL: <a href="https://fullscreen.spec.whatwg.org/">https://fullscreen.spec.whatwg.org/</a>
<dt id="biblio-grabkeyboard">[GrabKeyboard]
<dd><a href="https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GrabKeyboard">X11 GrabKeyboard API</a>. URL: <a href="https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GrabKeyboard">https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GrabKeyboard</a>
<dt id="biblio-lowlevelkeyboardproc">[LowLevelKeyboardProc]
<dd><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms644985(v=vs.85).aspx">LowLevelKeyboardProc documentation on MSDN</a>. URL: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms644985(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ms644985(v=vs.85).aspx</a>
<dt id="biblio-quartzeventservices">[QuartzEventServices]
<dd><a href="https://developer.apple.com/reference/coregraphics/1658572-quartz_event_services">Quartz Event Services</a>. URL: <a href="https://developer.apple.com/reference/coregraphics/1658572-quartz_event_services">https://developer.apple.com/reference/coregraphics/1658572-quartz_event_services</a>
</dl>
<h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2>
<pre class="idl def"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a> {
[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>] <span class="kt">void</span> <a class="nv" href="#dom-navigator-requestsystemkeyboardlock">requestSystemKeyboardLock</a>(<span class="kt">optional</span> <span class="kt">sequence</span><<span class="kt">DOMString</span>> <a class="nv" href="#dom-navigator-requestsystemkeyboardlock-keycodes-keycodes">keyCodes</a>);
[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>] <span class="kt">void</span> <a class="nv" href="#dom-navigator-cancelsystemkeyboardlock">cancelSystemKeyboardLock</a>();
};
</pre>
<h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2>
<div style="counter-reset:issue">
<div class="issue"> What level of support do we need on mobile? Is it enough to say that
it’s a keyboard-focused API and mobile devices typically don’t have
keyboards? What does Chrome do if you activate full-screen on a mobile
web site and hit Escape from an attached keyboard? It seems like that should
also be supported.<a href="#issue-72c48aba"> ↵ </a></div>
<div class="issue"> How does this proposal prevent malicious sites from taking all
key events and preventing the user from escaping?<a href="#issue-39c02e2a"> ↵ </a></div>
<div class="issue"> How could this be used (alone or in conjunction with
other APIs) to give the user a bad experience?<a href="#issue-f0dcdf2b"> ↵ </a></div>
</div>
<aside class="dfn-panel" data-for="dom-navigator-requestsystemkeyboardlock">
<b><a href="#dom-navigator-requestsystemkeyboardlock">#dom-navigator-requestsystemkeyboardlock</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-navigator-requestsystemkeyboardlock-1">2.1. requestSystemKeyboardLock</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-navigator-requestsystemkeyboardlock-keycodes-keycodes">
<b><a href="#dom-navigator-requestsystemkeyboardlock-keycodes-keycodes">#dom-navigator-requestsystemkeyboardlock-keycodes-keycodes</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-navigator-requestsystemkeyboardlock-keycodes-keycodes-1">2.1. requestSystemKeyboardLock</a> <a href="#ref-for-dom-navigator-requestsystemkeyboardlock-keycodes-keycodes-2">(2)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-navigator-cancelsystemkeyboardlock">
<b><a href="#dom-navigator-cancelsystemkeyboardlock">#dom-navigator-cancelsystemkeyboardlock</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-navigator-cancelsystemkeyboardlock-1">2.2. cancelSystemKeyboardLock</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="enable-keyboard-lock">
<b><a href="#enable-keyboard-lock">#enable-keyboard-lock</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-enable-keyboard-lock-1">2. Activating and Deactivating System Keyboard Lock</a>
<li><a href="#ref-for-enable-keyboard-lock-2">2.1. requestSystemKeyboardLock</a> <a href="#ref-for-enable-keyboard-lock-3">(2)</a>
<li><a href="#ref-for-enable-keyboard-lock-4">2.2. cancelSystemKeyboardLock</a> <a href="#ref-for-enable-keyboard-lock-5">(2)</a>
<li><a href="#ref-for-enable-keyboard-lock-6">3.2. Handling Keyboard Events</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="reserved-key-codes">
<b><a href="#reserved-key-codes">#reserved-key-codes</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-reserved-key-codes-1">2.1. requestSystemKeyboardLock</a> <a href="#ref-for-reserved-key-codes-2">(2)</a>
<li><a href="#ref-for-reserved-key-codes-3">2.2. cancelSystemKeyboardLock</a>
<li><a href="#ref-for-reserved-key-codes-4">3.2. Handling Keyboard Events</a> <a href="#ref-for-reserved-key-codes-5">(2)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="system-key-press-handler">
<b><a href="#system-key-press-handler">#system-key-press-handler</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-system-key-press-handler-1">3.1. System Key Press Handler</a>
<li><a href="#ref-for-system-key-press-handler-2">3.1.1. Registering</a>
<li><a href="#ref-for-system-key-press-handler-3">3.2. Handling Keyboard Events</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="register-a-system-key-press-handler">
<b><a href="#register-a-system-key-press-handler">#register-a-system-key-press-handler</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-register-a-system-key-press-handler-1">2.1. requestSystemKeyboardLock</a>
<li><a href="#ref-for-register-a-system-key-press-handler-2">3.2. Handling Keyboard Events</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="unregister-the-system-key-press-handler">
<b><a href="#unregister-the-system-key-press-handler">#unregister-the-system-key-press-handler</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-unregister-the-system-key-press-handler-1">2.2. cancelSystemKeyboardLock</a>
</ul>
</aside>
<script>/* script-dfn-panel */
document.body.addEventListener("click", function(e) {
var queryAll = function(sel) { return [].slice.call(document.querySelectorAll(sel)); }
// Find the dfn element or panel, if any, that was clicked on.
var el = e.target;
var target;
var hitALink = false;
while(el.parentElement) {
if(el.tagName == "A") {
// Clicking on a link in a <dfn> shouldn't summon the panel
hitALink = true;
}
if(el.classList.contains("dfn-paneled")) {
target = "dfn";
break;
}
if(el.classList.contains("dfn-panel")) {
target = "dfn-panel";
break;
}
el = el.parentElement;
}
if(target != "dfn-panel") {
// Turn off any currently "on" or "activated" panels.
queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(function(el){
el.classList.remove("on");
el.classList.remove("activated");
});
}
if(target == "dfn" && !hitALink) {
// open the panel
var dfnPanel = document.querySelector(".dfn-panel[data-for='" + el.id + "']");
if(dfnPanel) {
console.log(dfnPanel);
dfnPanel.classList.add("on");
var rect = el.getBoundingClientRect();
dfnPanel.style.left = window.scrollX + rect.right + 5 + "px";
dfnPanel.style.top = window.scrollY + rect.top + "px";
var panelRect = dfnPanel.getBoundingClientRect();
var panelWidth = panelRect.right - panelRect.left;
if(panelRect.right > document.body.scrollWidth && (rect.left - (panelWidth + 5)) > 0) {
// Reposition, because the panel is overflowing
dfnPanel.style.left = window.scrollX + rect.left - (panelWidth + 5) + "px";
}
} else {
console.log("Couldn't find .dfn-panel[data-for='" + el.id + "']");
}
} else if(target == "dfn-panel") {
// Switch it to "activated" state, which pins it.
el.classList.add("activated");
el.style.left = null;
el.style.top = null;
}
});
</script>