#Laggy website

5 messages · Page 1 of 1 (latest)

frozen spruce
#

Listen for events instead of using setInterval().

#

Based on the tiny portion of visible code, I infer what you need is a keydown even listener on the document.

Note that this approach should be used even if you have a fast computer. Your technique is never considered the correct way regardless of the computer.

#

This is not the purpose of requestAnimationFrame(). Its purpose is to let you update the visuals immediately before a repaint. The DOM has a set of events that elements can listen too. They were invented for the sole purpose of efficiently responding to user activity without the need to poll.

silver mist
frozen spruce