Say there is an
enum ArrowKey{
Up = "ArrowUp",
Right = "ArrowRight",
Down = "ArrowDown",
Left = "ArrowLeft"
}
Now when receiving a KeyboardEvent with e.key "ArrowUp" how is it easily checked that this string value exists in the enum? And how to pick out the right enum value afterwards?
e.keydirectly for your switch because whene.key === 'ArrowUp'thene.key === ArrowKey.Up. You could even consider using a const enum.