What about different keyboards?

Just like many if not all English-speaking country, the UK is using QWERTY keyboard.
As a French, I know that we use AZERTY keyboards in France; and I am sure there are different key placements in other countries.

My question is regarding the coding for the rotation of the Player.
Below is the code given by Rick:

image

If I code this with a QWERTY keyboard, the keys will be incorrect for an AZERTY keyboard for example (A and Q are inverted, same with W and Z, M is in a different position to open a map, etc)

How would go about fixing this?

Hi Julie,

Did you test the code with your keyboard? The WASD keys should be at the same position on your keyboard.

Regarding the A, Z and M keys, I would say: Test the code. Unity either maps the KeyCodes to the position on your keyboard or to the current layout of your keyboard. That’s something you’ll have to figure out first before you develop a solution for an non-existent problem.

If you want to allow the player to select their own keybindings, you could follow this tutorial:

I did not watch it completely but it looks as if this might be what you are looking for.


See also:

2 Likes

This is the description of Unity’s KeyCode enum:

Summary:
Key codes returned by Event.keyCode. These map directly to a physical key on
the keyboard. If “Use Physical Keys” is enabled in, these map directly to a physical
key on the keyboard. If “Use Physical Keys” is disabled these map to language
dependent mapping, different for every platform and cannot be guaranteed to work.
“Use Physical Keys” is enabled by default from 2022.1

I am not sure what ‘language dependent mapping’ means so, like @Nina said, you should test it. You would likely have to set up key mappings.

1 Like

I am using a QWERTY keyboard, but this is something that has often crossed my mind!

Thank you both. I will have a watch a bit later.
I guess I will have to cross that bridge when I get to it, instead of putting too much in my plate. Baby steps.

That’s a good idea. Complete the game first, then worry about new problems. :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms