-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 694 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 694 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
let looping = false;
const output = document.getElementById('output');
document.getElementById('startLoop').addEventListener('click', () =>{
if(looping) return;
looping = true;
output.textContent = "Loop iniciado. Pressione ESC para parar. \n";
const loop = () => {
if (!looping) return;
const timestamp = new Date().toLocaleTimeString();
output.textContent += `Looping... ${timestamp} \n`;
output.scrollTop = output.scrollHeight;
setTimeout(loop, 100);
};
loop();
})
document.addEventListener('keydown', (e) =>{
if(e.key === "Escape"){
looping = false;
output.textContent += "Loop encerrado. \n";
}
});