How can i know what keyboard configuration the players use?

Hi folks!
It’s not really a scripting issu 'cause i don’t have any code to share and i was just wondering, but how can i know if the players is using qwerty, azerty, dvorak, etc ?

I was thinking i could use a tutorial with just “move forward” and register the playet input to set the “move forward” key, but it seem too much prone to error or accidental input.I’d like to know if there is a panda way to know what keyboard the player is using and what’s your take on this ?

Firstly, as a dvorak user, I’m glad to see someone care about alternative keyboard layouts. :slight_smile: Of course Panda fully supports this.

You can use the raw-w, raw-a, raw-s, raw-d, etc. parameters to base.accept to get positional/layout-independent inputs. raw-w is fired when a user presses the key that would correspond to W on a qwerty keyboard. This allows you to define your key bindings in a layout-independent way.

But sometimes you need to know what key that is actually mapped to, eg. for displaying a helpful “press e to interact” prompt. This information can be obtained by using base.win.getKeyboardMap(), which returns a ButtonMap that allows you to look up which “raw” key corresponds to which “virtual” key.

More information and example code can be found in the manual:
https://docs.panda3d.org/1.10/python/programming/hardware-support/keyboard-support#raw-keyboard-events

1 Like

Hi! Sorry for the late reply, life kinda got on the way and i only had time to try recently.

Firstly, as a dvorak user, I’m glad to see someone care about alternative keyboard layouts

Ahah, my pleasure ! :slight_smile:

You can use the raw-w , raw-a , raw-s , raw-d , etc. parameters to base.accept to get positional/layout-independent inputs

Nice, it’s exacly what i wanted and works like a charm, thanks for the insight :slight_smile: