Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Pong!</title>
- <script>
- var run = function() {
- var canvas = document.getElementById("game");
- var ctx = canvas.getContext("2d");
- ctx.fillStyle = "red";
- ctx.fillRect(0, 0, 150, 75);
- ctx.fillStyle = "black";
- ctx.fillText("Mr. K was here", 10, 20);
- };
- var keypress = function(e) {
- if (e.keyCode == 38 || e.keyCode == 40) {
- alert(e.keyCode);
- }
- };
- setInterval(run, 20);
- window.addEventListener("keydown",keypress,false);
- </script>
- </head>
- <body onload="run()">
- <canvas id=game width=600 height=400></canvas>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement