-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
34 lines (28 loc) · 870 Bytes
/
example.js
File metadata and controls
34 lines (28 loc) · 870 Bytes
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
document.addEventListener("keydown",(event) => {
const keyName = event.key;
if (keyName === "Control") {
// do not alert when only Control key is pressed.
return;
}
if (event.ctrlkey) {
// Even though event.key is not 'Control' (e.g., 'a' is pressed),
// event.ctrlKey may be true if Ctrl key is pressed at the same time.
alert(`Combination of ctrlKey + ${keyName}`);
} else {
alert(`Key pressed ${keyName}`);
}
},
false,
);
// const deleteButton = document.querySelector('[data-delete]');
// deleteButton.addEventListener("click",(event)=>{
// if(event.key === 'Delete'){
// printsucess(keyName);
// }
// else{
// alert('failed :(');
// }
// })
// function printsucess(keyname){
// alert(`step 1 is completed${keyname}`);
// }