Created
August 14, 2017 20:54
-
-
Save beznosd/dd8de57ea3b25cc26790da74b3b74794 to your computer and use it in GitHub Desktop.
Skipping default controls of the browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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