\ key on a QWERTY UK keyboard

8,885

Solution 1

On the image you posted, / is left of the Right Shift, and \ is just above the Enter key.

Solution 2

I think it might be the easiest to simply remap a key.

For remapping certain keys you need two tools. First xev (commandline-tool) and second xmodmap (also commandline-tool). Both should be available in ubuntu without extra installing them.

  1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.

  2. xev will output some information about the pressed key. The third line is important. It should look similar to:

    state 0x10, keycode 110 (keysym 0xff55, Prior), same_screen YES,
    

    In this example Prior is the name of the behaviour the key is assigned to at the moment, the number keycode is the internal id to recognize the key. Now do this with another key i.e. PgDown give this output

    state 0x10, keycode 115 (keysym 0xff56, Next), same_screen YES,
    

    Here again the interesting part for us is keycode 115 and Next - the name of the behaviour.

  3. now when you want to swap the two keys use xmodmap.

     xmodmap -e "keycode 110 = Next"
    

    This changes the key with keycode 110 on your keyboard to the action Next. It's pretty simple.

    Note that if the key you are mapping should have a different meaning when used with the shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:

     xmodmap -e "keycode 53 = backslash bar"
    

Note: These change are for the active x session only and will be lost after reboot. When you want to save the changes permanently you have to run the following commands after the ones above:

xmodmap -pke >~/.Xmodmap

(This creates a files called .Xmodmap in your home directory.)

Then you have to create a file called .xinitrc in your home directory where you put this commandline xmodmap .Xmodmap in.


Source: https://askubuntu.com/questions/24916/how-do-i-remap-certain-keys

Share:
8,885

Related videos on Youtube

dorien
Author by

dorien

Assistant Professor at Singapore University of Technology and Design. Working on Machine learning and optimization algorithms for digital music and other novel applications.

Updated on September 18, 2022

Comments

  • dorien
    dorien over 1 year

    I wanted to know what other programmers do on laptops that do not have a \ key.

    I have a dell XPS13 ultrabook, which is also sold as a developer edition. Now this keyboard, has US layout, but I changed the software settings to querty uk (in order to be able to type á, â, à, ä), lacks the \ key due to the very large shift key. See hardware keyboard here. This is my virtual keyboard

    virtual keyboard.

    And with shift pressed: enter image description here

    Am I looking over this key? Is there some way to access it with another shortcut? Or should I map it to someplace else? I am using OpenSuse linux.

    • ssssteffff
      ssssteffff over 10 years
      If you press the \ physical key using UK qwerty, what character do you get?
  • dorien
    dorien over 10 years
    I know. Except I changed this layout to UK, I know the hardware is US, but I couldn't type accents. To clarify, I have added a snapshot of my virtual keyboard in the question.
  • m4573r
    m4573r over 10 years
    Alright, that wasn't very clear. Have you tries the us_intl layout?
  • dorien
    dorien over 10 years
    Yes US international would be a solution. Except that I am not used to it at all, let me explore it for a minute...
  • m4573r
    m4573r over 10 years
    it's basically the normal us qwerty with the possibility of typing the accents before the letters you want to accent.
  • dorien
    dorien over 10 years
    that seems to have the same effect as alt-tab (window switching)