Ubuntu – How to type “ñ” with a UK keyboard layout

keyboard-layout

How can I type "ñ" with a UK layout using altgr?

I'd like to be able to just press altgr+ and get "ñ".

Best Answer

CTRL+SHIFT+U and then write the unicode codepoint of the letter, for Ñ it is 00D1 and press SPACE. This works for any unicode character in most of the X applications.

Okay so it looks like I only read the title. If you want to use ALT Gr+N:

xkbcomp $DISPLAY keylayout.xkb

Open the keylayout.xkb with your favourite editor end search for the symbol which has the mapping for N, something like:

    key <AB06> {
    type= "FOUR_LEVEL_SEMIALPHABETIC",
    symbols[Group1]= [               n,               N,      braceright,               N ]
};

And change the third value (e.g. braceright) to ntilde and the fourt value (e.g. N) to Ntilde . Save and

xkbcomp keylayout.xkb $DISPLAY

After this it should work. (For me it does.) But it is only for this session, to make it permanent make a script named /etc/keylayout.sh like

#!/bin/bash
xkbcomp /etc/keylayout.xkb $DISPLAY

Make the script executable sudo chmod a+x /etc/keylayout.sh and add the next line to /etc/lightdm/lightdm.conf:

session-setup-script=/etc/keylayout.sh

Source for the ALT Gr method: link