JavaScript · Middle · Question 66 of 75
Which property should you use to detect the pressed key?
- ✓Correct answer:
event.key(e.g."Enter","a") -keyCodeis deprecated - 2
event.keyCode, because it's the most reliable - 3
event.which
Explanation
event.key gives the character respecting layout; event.code gives the physical key ("KeyA") - useful for game controls independent of keyboard layout.