We would like to know how to handle event for whole page.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-2.1.0.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!-- w w w .j a v a 2s.co m-->
$(document).keydown(function(e) {
console.log(e.keyCode);
if (e.keyCode == 76) {
console.log("pressed l!");
}
});
$(document).keydown(function(e) {
if (e.keyCode == 71) {
console.log("pressed g!");
}
});
});
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: