Q:

SyntaxError on "function x.y () {...}"?

How can I fix the following javascript error ? This is a handler for an ASP.NET page to disable postbacks when the enter key is pressed:
        <script type="text/javascript">
            function document.onkeydown() {

                if (event.keyCode == 13) {
                    event.returnValue = false;
                    event.cancel = true;
                }
            }
        </script>

A:

Note that document.onkeydown is not a valid function name.  You probably wanted to do this:
document.onkeydown = function(ev) {
  if (ev.keyCode == 13) {
  // ...
}

Or better:
document.addEventListener('keydown', function(ev) {
  if (ev.keyCode == 13) {
  // ...
});

