Last active
August 29, 2015 14:16
-
-
Save ishankhare07/fcdb3a60780e3d064b37 to your computer and use it in GitHub Desktop.
javascript detecting keypress
This file contains hidden or 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> | |
<head> | |
<title>key test</title> | |
</head> | |
<script> | |
window.onkeypress = check_return; | |
function check_return(event) { | |
var key = event.keyCode || event.which; | |
if(key === 13) { //acsii of 'enter' | |
//alert('you pressed enter!'); | |
window.location.assign('http://www.google.com/'); | |
} | |
} | |
</script> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment