Skip to main content

Change emacs keyboard layout

Solved!

The problem I had was that emacs -nw correctly used the gb keyboard layout. However when opening emacs in a new frame it would use a us keyboard layout, and resist efforts to change this.

From https://emacs.stackexchange.com/questions/62185/unable-to-change-keyboard-layout-in-exwm-emacs27-1 I found some clues and I now explicitly call setxkbmap -model pc105 -layout gb (added to my .bashrc) which has resolved the problem for me.

Original Post:

I use a uk keyboard, and my OS is setup and all my apps automatically use that layout too. However Emacs (27.2, built from repo) for some reason uses a us style layout. How can I change it to use the qwerty uk layout?

I have tried setting in my config/calling interactively:

(setq quail-keyboard-layout 'pc105-uk)

However whatever I choose doesn't appear to have any impact.

I have also tried interactively calling set-input-method "british". This has had some help in the shift+3 is now '£' instead of '#'. However other keys such as my '#' come out as '\'.

Please could I have some help? If it isn't obvious, I'm a newbie to Emacs, so answers that don't assume much knowledge would be appreciated thanks!

Edit: I have now found this thread.

https://emacs.stackexchange.com/questions/62185/unable-to-change-keyboard-layout-in-exwm-emacs27-1

I don't understand it, but I have found that starting Emacs with emacs -nw does resolve the problem. I would still like to find a solution where I can start Emacs in a window.