# Using a custom keyboard layout



## matrem_deam (Jun 6, 2021)

What my goal was:
I wanted to create a custom keyboard layout for my system, i bought a gaming keyboard with 40 keys and wanted to create one layer with all the letters, and when pressing right alt i would like it to switch to the other symbols (.,"# etc.)
This is my main motivation for using freebsd since i had a lot of problems doing it on linux and it would greatly improve my typing speed since i only have one arm.

What i tried:
i found other keyboard layouts in the /usr/share/syscons/keymaps directory and used the uk.iso.kbd one and modified it. Just to check i changed only one letter in the file (replaced q with p) and then when i updated the /etc/rc.conf with the changed uk.iso.kbd layout, by adding keymap=us.iso.kbd. Upon reboot it told me to use switch the keymap="uk.iso.kbd" with keymap="uk". I tried switching and not switching it and still nothing changed. Q stayed in place. What step did i miss or did wrong.
I also tried piping the us.iso.kbd layout in a new file my.iso.kbd with changed keybindings and still nothing happened.
I am also having trouble finding documentation on how to build a keyboard layout from scratch, for an example i am not sure what a lock state is inside the uk.iso.kbd file
Any good documentation or advice would be greatly appriciated.
Thanks in advance


----------



## Alain De Vos (Jun 6, 2021)

Lockstate is easy, that just the numlock.
Try first on a tty console and not in X and use kbdcontrol to load the keymap.
 I modified a kbd file and it worked immediately.


----------



## T-Daemon (Jun 7, 2021)

matrem_deam said:


> What my goal was:
> I wanted to create a custom keyboard layout for my system, i bought a gaming keyboard with 40 keys and wanted to create one layer with all the letters, and when pressing right alt i would like it to switch to the other symbols (.,"# etc.)


I'm not sure I understand this correctly, do you mean by pressing AltGr and releasing the key to switch to those other symbols?



matrem_deam said:


> i found other keyboard layouts in the /usr/share/syscons/keymaps directory and used the uk.iso.kbd one and modified it.
> ...
> Q stayed in place. What step did i miss or did wrong.


You modified the wrong key map. vt(4) is the default device on all supported versions to provide virtual terminal consoles, not syscons sc(4). You have to look at /usr/share/vt/keymaps/uk*.



matrem_deam said:


> Just to check i changed only one letter in the file (replaced q with p) and then when i updated the /etc/rc.conf with the changed uk.iso.kbd layout, by adding keymap=us.iso.kbd. Upon reboot


To see the effect of the modifications to the key map you don't need to set it in /etc/rc.conf and reboot the system. Copy the uk.kbd key map to a users home directory, execute after every edit: `kbdcontrol -l ~/uk`



matrem_deam said:


> I am also having trouble finding documentation on how to build a keyboard layout from scratch,


See man kbdmap(5)


----------

