-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
58 lines (56 loc) · 1.92 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
window.addEventListener('keydown', keyDown);
function keyDown(e){
let charKey = e.key;
let theKeyNum = charKey.charCodeAt();
const main = document.querySelector('main');
const div = document.createElement('div');
const keyName = document.createElement('p');
const keyNum = document.createElement('p');
main.appendChild(div);
div.appendChild(keyName);
div.appendChild(keyNum);
keyName.setAttribute('class', 'key-name');
keyNum.setAttribute('class','key-num');
if(charKey === undefined){
keyName.innerText = ':('
keyNum.innerText = ':(';
}else if(charKey === " "){
keyName.innerText = 'SpaceBar';
keyNum.innerText = theKeyNum;
}else{
keyName.innerText = charKey;
keyNum.innerText = theKeyNum;
}
let y = main.clientHeight;
let x = main.clientWidth;
scrollTo(x,y)
}
const mode = document.querySelector('.mode')
mode.addEventListener('click', modeSwitch);
function modeSwitch(){
let darkBody = document.querySelector('body');
const darkMd = Array.from(document.querySelectorAll('p'));
darkMd.forEach(p => p.classList.toggle('dark'))
darkBody.classList.toggle('dark');
if(mode.innerText === 'Dark Mode'){
mode.innerText = 'Light Mode';
}else{
mode.innerText = 'Dark Mode'
}
}
// const mode = document.querySelector('.mode')
// mode.addEventListener('click', modeSwitch);
// function modeSwitch(){
// let darkBody = document.querySelector('body');
// const darkMd = Array.from(document.querySelectorAll('p'));
// darkMd.forEach(p => p.classList.toggle('dark'))
// darkBody.classList.toggle('dark');
// if(mode.innerText === 'Dark Mode'){
// mode.innerText = 'Light Mode';
// }else{
// mode.innerText = 'Dark Mode'
// }
// }
const keys = document.querySelectorAll('#keyboard li');
const letter = document.querySelectorAll('letter');
console.log(letter.length);