Keyboard Events

Add a keydown event listener to the entire page
document.addEventListener(`keydown`, keyPressed)
Check the keyCode property on the event object
function keyPressed(event) {
  console.log(event.keyCode)
}
Every key on the keyboard has its own key code. Press different keys to see their key codes. To do something when a particular key is pressed, check the key code in an if statement.
function keyPressed(event) {
  if (event.keyCode == 65) {
    console.log(`the A key was pressed`)
  }
}