Ask Ubuntu Asked by Jhonnytunes on January 4, 2021
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.
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):
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
.
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.
Logout/login (reboot) and enjoy!
Answered by myrs on January 4, 2021
for gnome-shell, one just needs to edit this file: /usr/share/X11/xkb/symbols/pc. and then reboot.
Answered by 象嘉道 on January 4, 2021
I recently acquired a Lenovo E550 and had the same problem, I solved it by using xte
(from xautomation
) along with xmodmap
.
@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.
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.
@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.
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:
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:
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.
Answered by Hans on January 4, 2021
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.
Answered by Null Pointer on January 4, 2021
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).
Answered by Bahax on January 4, 2021
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 ;)
Answered by Danial Behzadi on January 4, 2021
It's a little bit complicated but you can do it. Follow these steps:
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,
Press the key you want to reconfigure. The output in the terminal will show you the keycode
(be careful, might have several).
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 current keymap table to your $HOME
, to override the defau:
xmodmap -pke > ~/.Xmodmap
Create or edit ~/.xinitrc
to load your configuration:
$EDITOR ~/.xinitrc
Add following lines
if [ -f $HOME/.Xmodmap ]; then
/usr/bin/xmodmap $HOME/.Xmodmap
fi
Most of the information above comes from ArchWiki article.
Answered by Ed Villegas on January 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP