forked from stemkoski/AR-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.html
45 lines (34 loc) · 710 Bytes
/
keyboard.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="js/keyboard.js"></script>
</head>
<body>
Open the Javascript console, and while the browser has focus, press the 'A' key.
<script>
console.log("Starting keyboard...");
var keyboard = new Keyboard();
keyboard.setOnKeyDown(
function(key)
{
if ( key == "A" )
console.log("Callback function: A");
}
);
loop();
function loop()
{
requestAnimationFrame(loop);
keyboard.update();
// Testing with the
if ( keyboard.isKeyDown("A") )
console.log("Key Down: A");
if ( keyboard.isKeyPressed("A") )
console.log("Key Pressed: A");
if ( keyboard.isKeyUp("A") )
console.log("Key Up: A");
}
</script>
</body>
</html>