Stop breaking browser navigation shortcuts. (#527)

On Linux Chrome I use ALT + Arrows to go back in the browser, but instead
it paginates between examples.

Fixed it by checking for special key modifiers and do nothing (to the let the browser handle it).
I think the user always intends a system shortcut if they use a modifier key.
This commit is contained in:
Henrik Sylvester Oddergaard
2024-05-11 17:54:34 +02:00
committed by GitHub
parent e5e90317bd
commit e6b7ae87b5
83 changed files with 249 additions and 0 deletions

3
public/arrays generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'switch';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'rate-limiting';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'sha256-hashes';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'channels';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'channel-synchronization';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'channel-buffering';

3
public/channels generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'goroutines';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'non-blocking-channel-operations';

3
public/closures generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'variadic-functions';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'testing-and-benchmarking';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'command-line-arguments';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'command-line-flags';

3
public/constants generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'variables';

3
public/context generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'http-server';

3
public/custom-errors generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'errors';

3
public/defer generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'panic';

3
public/directories generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'file-paths';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'temporary-files-and-directories';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'command-line-subcommands';

3
public/epoch generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'time';

3
public/errors generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'generics';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'spawning-processes';

3
public/exit generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'signals';

3
public/file-paths generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'line-filters';

3
public/for generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'constants';

3
public/functions generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'range';

3
public/generics generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'struct-embedding';

3
public/goroutines generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'custom-errors';

3
public/hello-world generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowRight") {

3
public/http-client generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'logging';

3
public/http-server generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'http-client';

3
public/if-else generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'for';

3
public/interfaces generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'methods';

3
public/json generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'regular-expressions';

3
public/line-filters generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'writing-files';

3
public/logging generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'environment-variables';

3
public/maps generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'slices';

3
public/methods generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'structs';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'functions';

3
public/mutexes generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'atomic-counters';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'timeouts';

3
public/number-parsing generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'random-numbers';

3
public/panic generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'sorting-by-functions';

3
public/pointers generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'recursion';

3
public/random-numbers generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'time-formatting-parsing';

3
public/range generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'maps';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'closing-channels';

3
public/rate-limiting generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'waitgroups';

3
public/reading-files generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'base64-encoding';

3
public/recover generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'defer';

3
public/recursion generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'closures';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'text-templates';

3
public/select generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'channel-directions';

3
public/sha256-hashes generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'url-parsing';

3
public/signals generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'execing-processes';

3
public/slices generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'arrays';

3
public/sorting generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'stateful-goroutines';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'sorting';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'context';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'mutexes';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'string-functions';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'recover';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'pointers';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'interfaces';

3
public/structs generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'strings-and-runes';

3
public/switch generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'if-else';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'directories';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'embed-directive';

3
public/text-templates generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'string-formatting';

3
public/tickers generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'timers';

3
public/time generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'xml';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'epoch';

3
public/timeouts generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'select';

3
public/timers generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'range-over-channels';

3
public/url-parsing generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'number-parsing';

3
public/values generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'hello-world';

3
public/variables generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'values';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'multiple-return-values';

3
public/waitgroups generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'worker-pools';

3
public/worker-pools generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'tickers';

3
public/writing-files generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'reading-files';

3
public/xml generated
View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
if (e.key == "ArrowLeft") {
window.location.href = 'json';

View File

@@ -7,6 +7,9 @@
</head>
<script>
onkeydown = (e) => {
if (e.ctrlKey || e.altKey || e.shiftKey) {
return;
}
{{if .PrevExample}}
if (e.key == "ArrowLeft") {
window.location.href = '{{.PrevExample.ID}}';