The second piece of code you specify a listener directly on the HTMLElement.
This is not deprecated but it's not the way to go.
document.onkeydown = function(e) {
//do stuff with this
};
The first piece you specify a listener for an HTMLElement. This way you can specify multiple events for an action.
This is definitely the way to go.
window.addEventListener("keydown",eventReaction,false);
Note: addEventListener
is supported for modern browsers and IE>8
PS: Bad questions don't exist, only bad answers ;)