Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // javascript
- /*global
- alert, confirm, console, Debug, opera, prompt, WSH, strict
- */
- var canvas = document.getElementById("canvas"),
- context = canvas.getContext("2d"),
- width = window.innerWidth,
- height = window.innerHeight,
- ratio = window.devicePixelRatio;
- canvas.width = width * ratio;
- canvas.height = height * ratio;
- canvas.style.width = width + "px";
- canvas.style.height = height + "px";
- context.scale(ratio, ratio);
- document.addEventListener('keydown', function (e) {
- "use strict";
- if (e.keyCode === 'D'.charCodeAt(0)) {
- alert("right");
- } else if (e.keyCode === 'A'.charCodeAt(0)) {
- alert("left");
- } else if (e.keyCode === 'W'.charCodeAt(0)) {
- alert("up");
- } else if (e.keyCode === 'S'.charCodeAt(0)) {
- alert("down");
- }
- });
- // html
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>CHANGE HISTORY</title>
- </head>
- <body style="margin: 0px; overflow: hidden">
- <canvas id="canvas"></canvas>
- <script type="text/javascript" src="main%20(2).lnk"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement