This link would launch a jupyter notebook.
When the page is loaded,
typing h, would launch a modal ("Keyboard shortcuts")
typing f, would launch another modal "Find and Replace"
How to have a page support to typing keyboard to launch a modal?
This link gives some inspiration inside modal.
This and this give examples about a single element, although I am asking an approach to listen keypress event on whole page
question
Here is my code which is trying to listen any keypress
<!DOCTYPE html>
<html>
<head>
<script>
i = 0;
$(document).querySelector('#myDiv').addEventListener('keyup', function (e) {
$("span").text(i += 1);
})
</script>
</head>
<body>
<div class="container" id="mydiv" tabindex="0">
<p>Keypresses: <span>0</span></p>
</div>
</body>
</html>
How to make this code work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…