File tree Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -277,3 +277,26 @@ sup {
277
277
.result-no-output {
278
278
font-style : italic;
279
279
}
280
+
281
+ # help-overlay {
282
+ position : fixed;
283
+ display : none;
284
+ width : 20% ;
285
+ height : 60% ;
286
+ top : 10% ;
287
+ left : 40% ;
288
+ right : 0 ;
289
+ bottom : 0 ;
290
+ background-color : rgba (225 , 225 , 225 , 1 );
291
+ z-index : 2 ;
292
+ cursor : pointer;
293
+ border-width : 3px ;
294
+ border-color : black;
295
+ border-style : solid;
296
+ border-radius : 25px ;
297
+
298
+ padding : 10px ;
299
+ }
300
+ # help-title {
301
+ text-align : center;
302
+ }
Original file line number Diff line number Diff line change @@ -623,7 +623,7 @@ aria-label="Show hidden lines"></button>';
623
623
624
624
( function chapterNavigation ( ) {
625
625
document . addEventListener ( 'keydown' , function ( e ) {
626
- if ( e . altKey || e . ctrlKey || e . metaKey || e . shiftKey ) {
626
+ if ( e . altKey || e . ctrlKey || e . metaKey ) {
627
627
return ;
628
628
}
629
629
if ( window . search && window . search . hasFocus ( ) ) {
@@ -643,6 +643,42 @@ aria-label="Show hidden lines"></button>';
643
643
window . location . href = previousButton . href ;
644
644
}
645
645
}
646
+ function showHelp ( ) {
647
+ document . getElementById ( "help-overlay" ) . style . display = "block" ;
648
+ let help = `<h2 id="help-title">Keyboard shortcuts</h2>` ;
649
+ help += "<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>" ;
650
+ help += "<p>Press <kbd>s</kbd> to search in the book</p>" ;
651
+ help += "<p>Press <kbd>?</kbd> to show this help</p>" ;
652
+ help += "<p>Press <kbd>Esc</kbd> to hide this help</p>" ;
653
+
654
+ document . getElementById ( "help-overlay" ) . innerHTML = help ;
655
+
656
+ document . addEventListener ( 'keydown' , function ( e ) {
657
+ if ( e . altKey || e . ctrlKey || e . metaKey || e . shiftKey ) { return ; }
658
+
659
+ switch ( e . key ) {
660
+ case 'Escape' :
661
+ e . preventDefault ( ) ;
662
+ hideHelp ( ) ;
663
+ break ;
664
+ }
665
+ } ) ;
666
+ }
667
+ function hideHelp ( ) {
668
+ document . getElementById ( "help-overlay" ) . style . display = "none" ;
669
+ }
670
+
671
+ if ( e . shiftKey ) {
672
+ switch ( e . key ) {
673
+ case '?' :
674
+ e . preventDefault ( ) ;
675
+ showHelp ( ) ;
676
+ break ;
677
+ }
678
+
679
+ return ;
680
+ }
681
+
646
682
switch ( e . key ) {
647
683
case 'ArrowRight' :
648
684
e . preventDefault ( ) ;
Original file line number Diff line number Diff line change 63
63
<script src =" {{ resource " toc.js" }} " ></script >
64
64
</head >
65
65
<body >
66
+ <div id =" help-overlay" ></div >
66
67
<div id =" body-container" >
67
68
<!-- Work around some values being stored in localStorage wrapped in quotes -->
68
69
<script >
You can’t perform that action at this time.
0 commit comments