-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (36 loc) · 1.23 KB
/
script.js
File metadata and controls
41 lines (36 loc) · 1.23 KB
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
document.querySelector("#textWithLF").addEventListener("input", () => {
document.getElementById('textNonLF').value = document.getElementById('textWithLF').value.replaceAll('\r', '').replaceAll('\n', ' ');
});
document.querySelector("#copy").addEventListener("click", () => {
navigator.clipboard.writeText(document.getElementById('textNonLF').value);
});
document.querySelector("#select-all").addEventListener("click", () => {
document.form.textNonLF.focus();
document.form.textNonLF.select();
});
document.querySelector("#delete").addEventListener("click", () => {
document.getElementById('textWithLF').value = '';
});
document.querySelector("#focus").addEventListener("click", () => {
document.getElementById('textWithLF').focus();
});
document.querySelector("html").addEventListener("keydown", (e) => {
if(e.ctrlKey || e.metaKey){
switch(e.code){
case 'KeyA':
document.querySelector("#select-all").click();
break;
case 'KeyC':
document.querySelector("#copy").click();
break;
case 'KeyK':
document.querySelector("#delete").click();
break;
case 'Semicolon':
document.querySelector("#focus").click();
break;
default:
break;
}
}
});