Sorry, I forgot to mention a problem with the key code, but first …
Again, this just goes back to basic debugging. You have a console.log statement in there. Good. But it is in the second layer of code, in the switch statement (third if you count the case as another layer). My first instinct, if it isn’t making it to the second layer of code is to check the first layer of code, at the beginning of key(). Put a statement there,
console.log("key"); as the first statement in key(). When you do that we see that key() is in fact getting called. OK, so why isn’t the switch working. My next instinct is to console.log that event so I can make sure I’m getting exactly what I think I’m getting. If you do that, you will find your mistake. Examine the object that is event and see what’s in there.
I’m getting concerned that maybe I’m doing you a disservice. I’ve tried to explain how I debug these things as I help you but you don’t seem to be picking up on this. The mistake you made here is a really easy mistake to make, but is also a really easy one to debug. Just keep stepping back and see if what you think is happening is really happening. It’s concerning that your first instinct wasn’t to see if it was making it into key() at all but just assumed that if it made it into key() that it must make it into the case of that switch statement.
With regards to your update function, you’re right, that is the basic idea, though, I might have chosen a more meaningful name than “update”. My only concern is that I don’t see where that puts the data into the state. There’s another little problem, but you’ll find that easy enough.