You shouldn't be using characters typed by keys unless you're accepting text input. Key codes correspond one-to-one to physical keys on the keyboard; characters do not, they're mapped by the operating system depending on user preferences.
Use this tool to see for yourself: event.key you're using changes depending on the active layout, but the numeric key code in event.which stays the same.
Steps to reproduce:
You shouldn't be using characters typed by keys unless you're accepting text input. Key codes correspond one-to-one to physical keys on the keyboard; characters do not, they're mapped by the operating system depending on user preferences.
Use this tool to see for yourself:
event.key
you're using changes depending on the active layout, but the numeric key code inevent.which
stays the same.