I just purchased a Lenovo thinkpad and I am so proud of everything in it. It feels just as rock solid as the Linux kernel :P.

The problem is that Lenovo decided to remove the context menu key that is the key that does the right click stuff. They replaced it by a print screen key. My keyboard has its numeric part with some buttons above it. There is a magnifying glass key that I would like to remap to open the context menu or be the right click key. Is it possible to do this?

I've tried searching for other related questions but I only found Q&As on how to add options to the Nautilus context menu. I want to to map a physical key of my keyboard to open this menu. Just like before. It also appears that Dell is dropping this key in their inspiron keyboard. I dont know whats going on since I use the keyboard more than mouse.

Thanks in advance.

  • 3
    Please install xbindkeys with sudo apt-get install xbindkeys. Then in a terminal run xbindkeys -k and type the key you want to change. Can you add the output to your question?
    – Seth
    Commented Dec 31, 2012 at 0:50
  • "NoCommand" m:0x50 + c:46 Mod2+Mod4 + l Commented Dec 31, 2012 at 4:17
  • Who would want a Print Screen key where they'd expect a Menu key? I seriously wonder how drunk you are allowed to show up to work at Lenovo. Anyway, note that you don't need an .Xmodmap generated by xmodmap -pke to start with, you can as well just put your binding in an empty file. Also, look at what @Baha_hi found out below. Commented May 16, 2016 at 16:24

10 Answers 10


It's a little bit complicated but you can do it. Follow these steps:

Detect keycode

  1. Run xev to detect the keycode:

    xev | grep keycode
            state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
            state 0x0, keycode 107 (keysym 0xff67, Menu), same_screen YES,
            state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
  2. Press the key you want to reconfigure. The output in the terminal will show you the keycode (be careful, might have several).

Test mapping

  1. Set new mapping temporarily, for me it's keycode 107:

    xmodmap -e "keycode  107 = Return NoSymbol Return"

If the key behave as expected, you can save the config.

Save your config

  1. Save your current keymap table to your $HOME, to override the defau:

    xmodmap -pke > ~/.Xmodmap
  2. Create or edit ~/.xinitrc to load your configuration:

    $EDITOR ~/.xinitrc
  3. Add following lines

    if [ -f $HOME/.Xmodmap ]; then
            /usr/bin/xmodmap $HOME/.Xmodmap


Most of the information above comes from ArchWiki article.

  • There is a problem. When I press the button 'l' is marked. I checked it at xev and it give me the 46 keycode which is assigned to the L l letter. Maybe it doesnt have a keycode a take one. Commented Dec 31, 2012 at 18:05
  • @Jhonnytunes. Check that your keyboard layout is correct. You can change your model typing ` sudo dpkg-reconfigure keyboard-configuration`. Commented Dec 31, 2012 at 20:13
  • Still the same behaivor. I tried different thinkpad models and nothing. Commented Dec 31, 2012 at 21:47
  • BTW my thinkpad is an E530c and doesnt appear in the keyboard list. Commented Dec 31, 2012 at 22:32
  • If this is your keyboard layout, maybe the key next to «Delete» is actually «Context menu» (the function you are looking for). Otherwise, reconfigure another key or ask directly Lenovo's desk which layout you should choose. Commented Jan 1, 2013 at 1:51

I found here that using: shift+F10 opens the context menu.

I know it's not the best solution but I thought it could help for temporary use!

P.S: I have e530c too, and I tested this on Debian 7 (Wheezy).

  • on ubuntu 20 it opens application menu, which is the one that is shown when you right click on title bar of an application Commented Mar 15, 2021 at 7:22
  • Did you ever found a way to rebind the shift + F10 keybind? Commented Mar 28, 2023 at 23:22
  • @ManuelMartinez I didn't try that.
    – Baha
    Commented May 3, 2023 at 10:24

This did the trick for me. For me the keycode for "PrtSc" button on my thinkpad is 107. I found that by "xev" tool in ubuntu.

xmodmap -e "keycode  107 = Menu"

This is a temporary change.

You can make this permanent by adding this command to /etc/profile and it will execute everytime you boot and it will be a permanent change.


I recently acquired a Lenovo E550 and had the same problem, I solved it by using xte (from xautomation) along with xmodmap.

Why the other answers won't work entirely?

  1. @Ed Villegas (nor @Null Pointer) answer won't work because some of the keys located above the numeric part are not unique keys by themself (e.g. the lock key is related to the Super+L combination). When xev is used to try to find the lock key keycode it returns both the Super and the L keycodes, you just have to interpret the xev output line by line.

  2. For @Bahax and @John Finegan: Shift+F10 is a context menu key, it doesn't work in all the applications and it doesn't provide the same functions as Menu. If you select a file in the file explorer and press Menu the context menu for the file itself should pop-up, this does not happen with the Shift+F10 combination, it would provide a context menu for the window instead.

  3. @Danial Behzadi takes a similar approach to the people in the 2nd item, but linking the keyboard combination to one key through a keystroke simulator, it will link the key to the Shift+F10 and provide the same result.

The answer that works

It is important to take into account that the key that is not present in the ThinkPad keyboard is the Menu (that is it's name), it is shown in the following picture:

Menu key

Although the key is not present, it's keycode should exist in your computer, you can find it by printing the keycode table with xmodmap -pke | grep Menu which should give you something like:

xmodmap output

With that in mind, install xautomation (in order to use xte for keystroke simulations) like in @Danial Behzadi answer:

sudo apt-get install xautomation

And create a custom shortcut, in the Trigger press the key that you want to be the shortcut, and in the Action paste xte 'key Menu'. Apply and test.


The following finally worked for me!

I'm have had the same problem with my Huawei Matebook 14 where the menu key is missing. Although I show how to map the menu operation to the right control (as I personally don't use it), this instruction works for any button.

The method works permanently.

Full guide (steps):

  1. Know the key code you want to bind Menu command to. Execute :

    xev | grep keycode

    then press your button and remember the code. E.g. I want my Right control to call the context menu. I press it, and get the code: 105.

  2. Modify the keycodes configuration file:

    Note: you need to do this as a super user.

    Optional but highly recommended! Make a backup of the configuration file:

    sudo cp /usr/share/X11/xkb/keycodes/evdev /usr/share/X11/xkb/keycodes/evdev_back

    Open the file to edit:

    sudo vim /usr/share/X11/xkb/keycodes/evdev
    # or use any other editor e.g. 
    # sudo gedit /usr/share/X11/xkb/keycodes/evdev

    Find a line with the original mapping (in my case, <RCTL> = 105;), comment it and add the new mapping of the menu command to the desired key (in my case, <MENU> = 105;)

    // the old mapping commented 
    // <RCTL> = 105;
    // the new mapping
    <MENU> = 105;

    save and close the file.

  3. Logout/login (reboot) and enjoy!

  • 1
    I like this approach, too. For the Lenovo PrtSc key, this worked to obtain Menu funtionality on a Carbon X1 Gen 9 with Pop!_OS 21.04.
    – Rasmus
    Commented Jul 5, 2021 at 16:32
  • 1
    This should be the answer. xmodmap is deprecated and external software shouldn't be a requirement.
    – r_31415
    Commented May 6, 2022 at 1:00

I finally found the way to do this after hours of tests and fails :D

First of all install xautomation:

sudo apt-get install xautomation

Then head to the Shortcut tab of Keyboard section in Ubuntu System Settings. First go to Screenshots entry and remap the actions to another key or disable them if you want. I replaced PrtSc(Print) key by the Thinkpad black button (Launch1).

Now go to Custom Shortcuts section and add a shortcut. name it whatever you like, e.g. Menu. In Command field insert this:

xte 'keydown Shift_L' 'key F10' 'keyup Shift_L'

The work is done! It's working like a miracle ;)


Tested on ubuntu 20.10


Find menu key

  1. Run $ xmodmap -pk | grep "Menu"
  2. Example output
    135     0xff67 (Menu)   0x0000 (NoSymbol)   0xff67 (Menu)   
    147     0x1008ff65 (XF86MenuKB) 0x0000 (NoSymbol)   0x1008ff65 (XF86MenuKB) 
  3. If there are multiple results try each of them to make sure we have the correct key code
  4. Try the key(s) from above result
  • $ xdotool key Menu
  • $ xdotool key XF86MenuKB
  1. Remember which one worked, for example in my case "Menu" worked

Set the shortcut

  • Go to Setting -> Keyboard Shortcuts -> Scroll till you see Custom shortcuts -> Click on +
  • A popup will open, fill as following
    • Name: give some logical name
    • Command: xdotool key Menu
    • Shortcut: as per you choice, for example in my case i assigned combination of right alt+printscreen

PS: install required packages if not already installed


for gnome-shell, one just needs to edit this file: /usr/share/X11/xkb/symbols/pc. and then reboot.

  • yeah this didn't work for me and requires more detail than what you've provided here. Perhaps a working example. Commented Oct 20, 2022 at 15:01

My solution for the Gnome3 shell (on Ubuntu 20.04) using xte or xdotool:

In system settings -> keyboard shortcuts, I create a custom shortcut:

xte 'keyup Print' 'key Menu'


xdotool keyup Print key --clearmodifiers Menu

That I assign to the Print key.

Importantly, I have to include the command to release the key that triggers the command, (in this case the Print key).

If I want to assign a combination like Shift+Print, the --clearmodifiers option of xdotool does the same for any modifiers (Shift, Ctrl, etc.).


  • In the Unity shell (on Ubuntu 16.04), the keyup and modifiers part was not necessary, but in the Gnome3 shell (on Ubuntu 20.04), the shortcut will not work without it.

  • Unlike using xmodmap, this persists after suspend.

Extension: Combination with xmodmap

I noticed that the xdotool command sometimes behaves in unexpected ways. E.g. while renaming a file in Nemo file manager, it will not show the context menu and cancel renaming.

So I followed @Ed Villegas' answer to create an xmodmap configuration that is run on startup. To reactivate the remapping after suspend, I changed my keyboard shortcut (still assigned to the Print key) to execute:

/bin/bash -c "xdotool keyup Print key --clearmodifiers Menu && /usr/bin/xmodmap $HOME/.Xmodmap"

In this way, the first use of the Print key after suspend will emulate the menu key using xdotool, while after that, it will be remapped to the menu key.


4 simple lines in your shell startup i.e. .zshrc

mysetting=$(xmodmap -pke | grep 135)
if [ $mysetting != 'keycode 135 = Control_R NoSymbol Control_R' ]; then
  sleep 4 && xmodmap ~/.Xmodmap &

In my case I keep hitting the menu button instead of right CTRL button. So I added this to my shell startup which also gets auto-launched on system boot via start-up items, opens my terminal. Yes there's a lag on the first terminal load, but after that, no such lag even if closing terminal and launching new one. For other remapping see previous answers to locate the mapping you need and you can modify this script accordingly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .