Detecting which key is pressed - is this a good way?
===

I found a simple code on the internet a while ago... can't find the spesific site for it, but the code was made in 2005. So, I wondered if this was a good way of doing this:

This is in the HTML:

    <body onload="document.body.focus();" onkeyup="return keypressed(event)">

When the key is up it calls this function in JavaScript:

    function keypressed(e) {
        var intKey = (window.Event) ? e.which : e.keyCode;
        if (intKey == 13) { // 13 = enter key
            //something happens if the key is clicked
        }
            // here, you can add as many if sentences for key strokes as you want! (same as first)

    return true;
    }

What I mean is that the code is 7 years old (maybe more!) and I thought it might be a little or very outdated!

My questions:

1. Is there a better way of doing this or is this still a good way? (I don't want to use jQuery for this code, because I don't want to use it just for one function)

2. Do I really need this code: `onload="document.body.focus();"`? (I have not programmed this code, so I don't know.)