Copy to a server, or in the directory do: python -m SimpleHTTPServer 8080
While this is likely broadly compatible (no HTML5 specific features like audio or canvas), it is HTML5.
keyDown and keyUp should update a key map that is checked during poll interval, rather than acting directly.