I cannot get preventDefault()
to work.
Here are some different code variations I have tried:
First:
$(document).keyup(function (evt)
You are using JQuery, which normalises the differences between browsers, so you only need to to check the evt.which property. See the JQuery documentation: http://api.jquery.com/keyup/
As others have said - keyup is too late to stop the processing of the key. Use keydown or keypress instead. http://api.jquery.com/category/events/keyboard-events/