Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
55 lines (52 loc) · 1.48 KB
/
Copy pathindex.html
File metadata and controls
55 lines (52 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>The Powder Toy</title>
<style>
body {
margin: 0;
background: #000;
overflow: hidden;
}
canvas {
display: block;
width: 100vw !important;
height: 100vh !important;
image-rendering: pixelated;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script src="powder.js"></script>
<script>
var canvas = document.getElementById('canvas');
canvas.addEventListener('contextmenu', e => e.preventDefault());
var shiftHeld = false;
document.addEventListener('keydown', e => {
if (e.key === 'Shift') shiftHeld = true;
});
document.addEventListener('keyup', e => {
if (e.key === 'Shift') shiftHeld = false;
});
canvas.addEventListener('mousedown', e => {
if (shiftHeld && e.button === 0) {
e.preventDefault();
var rightClick = new MouseEvent('mousedown', {
button: 2,
buttons: 2,
clientX: e.clientX,
clientY: e.clientY
});
canvas.dispatchEvent(rightClick);
}
});
create_powder({
canvas: canvas,
print: console.log,
printErr: console.error
});
</script>
</body>
</html>