-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (30 loc) · 912 Bytes
/
script.js
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
const text = document.getElementById('text');
const keys = document.querySelectorAll('#key');
const textArea = document.getElementById('textArea')
const word = 'My keyboard'
window.onload = function () {
text.innerText = word
textArea.focus()
}
// #40a8f6
function onkey(k){
addEventListener('keydown', function keydown(keydown) {
if (keydown.key == k.innerText) {
k.style = `background: #0c0cce !important; color: white !important;`
setTimeout(() => {
k.style = `background: #000103 !important; color: white !important;`
}, 300);
}
textArea.focus()
})
}
keys.forEach(key => {
onkey(key)
key.onclick = function () {
textArea.value += key.innerText
}
});
addEventListener('keydown', function keydown(keydown) {
console.log(keydown.key);
keys.style = `background: #40a8f6 !important;`
})