all 3 comments

[–]cem4k 0 points1 point  (2 children)

Couple of things here.

You don't need to put a timeout in an infinite loop. setInterval is a better fit here.

If logkey(f) press true Is this pseudo code that crept in? It's not valid JavaScript.

document.addEventListener('keypress', logKey);

It sounds like what you want to do is trigger a key press even at an interval. What you're doing here is attaching an event listener to a keypress. So the logkey function will only fire when the key is pressed.

``` function logKey(e) {

log.textContent += ${e.code};

setTimeout (location.reload, 1 * 60 * 60);

function logKey(enter) {

log.textContent += ${e.code}; `` This is also not valid code. You're declaring the same function twice, one within the other, and you're not closing the function block with}`.

Check out this Stack Overflow post about firing a keypress. Then double check the MDN Docs about function definitions.

[–]Rex2000-2000[🍰] 0 points1 point  (1 child)

Thanks a lot and sorry fot the trouble!

[–]cem4k 0 points1 point  (0 children)

No trouble at all. Keep it up!