Nothing wrong with the javascript. It returns true whenever you hit enter, 0-9, A-Z or a-z. False otherwise.
So describe the error behavior. What is it doing/not doing?
Try this, comparing with key directly using regex instead of keycode
var ew = event.key;
if( /[A-Za-z0-9 ]/.test(ew))
return true;