I recently used VirtualBox to install a Kali Linux machine on it. Because I have a German QWERTZ keyboard instead of the English standard QWERTY, the mapping of the keys was all over the place. This is why I had to change the keyboard layout in Kali Linux.
Option 1 - Use the Command Line
Because the key mapping is incorrect, using the console to write commands can be quite annoying. If you want to use the console, I would recommend simply copy/pasting the command.
$ setxkbmap -layout <countrycode>
You only have to insert the two-letter country code. For example
us for English or
de for German.
Keep in mind that the standard shortcut for pasting in the terminal is CTRL+SHIFT+C (STRG+UpArrow+C).
Option 2 - Use the GUI
To prevent typing nonsense and needing to find the correct country code, you could also use the second option, which is to use the GUI.
Go to the Kali Linux ‘Settings’
Under ‘Hardware’ choose the ‘Keyboard’ option.
Then go to the ‘Layout’ tab.
In the ‘Keyboard layout’ table click on the existing layout (by default English), click on edit and choose your language.
I had a problem with this method. The layout would not update. If this is the case try to toggle the ‘Use system defaults’ button on and off again. For me, this updated the layout and my typing finally made sense.