JavaScript · Middle · Question 66 of 75

Which property should you use to detect the pressed key?

Explanation

event.key gives the character respecting layout; event.code gives the physical key ("KeyA") - useful for game controls independent of keyboard layout.

Further reading

Problem with a question

JavaScript · Middle · question 66

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz