Skip to content

Instantly share code, notes, and snippets.

@beznosd
Created August 14, 2017 20:54
Show Gist options
  • Save beznosd/dd8de57ea3b25cc26790da74b3b74794 to your computer and use it in GitHub Desktop.
Save beznosd/dd8de57ea3b25cc26790da74b3b74794 to your computer and use it in GitHub Desktop.
Skipping default controls of the browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Skipping default controls of the browser</title>
</head>
<body>
<a href="#f" id="1">first link</a>
<a href="#s" id="2">second link</a>
<a href="#t" id="3">third link</a>
<script>
document.onkeydown = function(e) {
if (document.activeElement.id === '3' && e.which === 9) {
e.preventDefault();
var firstEl = document.getElementById('1');
firstEl.focus();
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment