-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
40 lines (27 loc) · 947 Bytes
/
test.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
<html>
<head>
<title>Test Script</title>
</head>
<body style="background: #3c2831">
</body>
<script>
document.addEventListener('keyup', function (event) {
const userInput = event.key.toLowerCase(); // Convert input to lowercase for case-insensitivity
console.log(userInput);
if (userInput === 'k' || userInput === 'e' || userInput === 'y' || userInput === 'b' || userInput === 'o' || userInput === 'a' || userInput === 'r' || userInput === 'd') {
// Check if the user is spelling "keyboard" one key at a time
checkForCompleteWord();
}
});
let typedCharacters = '';
function checkForCompleteWord() {
typedCharacters += event.key.toLowerCase();
console.log(typedCharacters);
if ('keyboard' in typedCharacters) {
console.log('User typed "keyboard"!');
// Reset typed characters for the next detection
typedCharacters = '';
}
}
</script>
</html>