10

I have Lenovo Thinkpad Yoga 14 which has PrtSc key on the keyboard. I personally find this key totally useless as I prefer using Screenshot application to select the required area and take a snapshot. I am trying to change its functionality to the Menu key, which can be used to access context menus similarly to right clicking. But I am not able to find this setting. How to do it?

enter image description here

ændrük
  • 76,794
a13e
  • 203
  • Just a pointer, capturing screenshot of a selected area should be accessible by +. – pomsky Nov 15 '17 at 16:35
  • @pomsky Thank you so much for your input. Actually I have already done this. But I want to basically change its functionality to "Right Click" whenever I click on any icon or file or directory. – a13e Nov 15 '17 at 16:46
  • @pomsky that's the catch here. My keyboard does not have Menu Key and I really want to configure my PrtSc key into Menu Key. PrtSc is in between Alt and Ctrl on Lenovo Thinkpad Yoga 14. – a13e Nov 15 '17 at 16:56
  • Yes. shift+f10 always works. Thank you for your input. I am waiting for some new answers. – a13e Nov 15 '17 at 16:59
  • shift+f10 does bring up a context menu but if the focus of the mouse pointer is in an application, Firefox for instance, then the context menu inside Firefox is brought up. The OP said "I prefer using Screenshot application..." so that is not exactly his end goal IMO. See https://askubuntu.com/a/254822/340383 for reference to how Gnome binds these keys. – bgoodr Feb 21 '18 at 16:24

5 Answers5

8

Xmodmap is deprecated for recent Ubuntu versions and because it does not persist when rebooting/suspending/changing tty, it is better to hack the X keyboard extension, or xkb.

To do so:

  • First, make a backup copy of your original file /usr/share/X11/xkb/keycodes/evdev

  • Edit the file and set

    alias <MENU> = <PRSC>;

    instead of what was defined before. It will assign the keycode assigned to <PRSC> to <MENU>.

  • Reboot, or restart Xorg.

Hence under X.Org server, your PrSc key becomes a Menu Key and it does persist in any case.

  • This will require fixing when this file is updated. It's easier to stuff an xmodmap command into your ~/.xsession or however you configure your desktop. – sarnold Mar 25 '20 at 22:08
  • @sarnold even if it seems easier to use a xmodmap, command, this way of re-binding is the best I found until now (suspendind and tty switching resilient). By the way xmodmap is deprecated in Ubuntu 19. Does this file could be updated automatically by the system? Please correct me if I am wrong, thanks!! – Rémy Hosseinkhan Boucher Mar 25 '20 at 23:12
  • 1
    Rémy, note that this package has changed every release, and was updated in 12.04 LTS and 18.04 LTS. Your changes would have been overwritten on every distro upgrade, as well as at least twice in those two LTS releases: https://launchpad.net/ubuntu/+source/xkeyboard-config User configuration changes should be made in user home directories or /etc/, not to packaged files in /usr. – sarnold Mar 31 '20 at 18:10
  • thank u @sarnold, i did not know it ! – Rémy Hosseinkhan Boucher Nov 29 '20 at 10:40
  • I'm not sure why, but this no longer works for me in Kubuntu 23.04: the key still acts as PrtSc. Adding the line worked perfectly before in 22.10 and before. – Fern Moss Apr 25 '23 at 00:34
3

As Roman Zotov shared, there is truly no need to reapply the whole keyboard mapping. Thanks for that! Just use the first two steps to find correct keycode and apply the change for one key only.


I had the same problem with my T480 with Linux Mint 19 but I managed to fix it using these steps from Fedora forum:

  1. Save the current keyboard map to a new file

    xmodmap -pke > ~/.xmodmap

  2. In the file find

    keycode 107 = Print Sys_Req Print Sys_Req

    change it to

    keycode 107 = Menu NoSymbol Menu

    and save it.

  3. Load the modified keymap

    xmodmap ~/.xmodmap

Now it should work (it does for me) but reboot makes it into default settings.

To fix that, I added the command from step 3. as a start-up command. All works great now.


Source: https://forums.fedoraforum.org/showthread.php?300542-ThinkPad-X240-Remap-PrtSc-key-to-Right-Click-Menu-Context-Menu

3

You don't need to copy whole keyboard map. Just run on start-up

xmodmap -e 'keycode 107 = Menu NoSymbol Menu'

it will change mapping for one keycode. On my ThinkPad T580 PrtSc code is 107.

3

As a workaround you may access the right click functionality by (the "menu" key) or Shift+F10 combintion.

The menu key looks like this:

enter image description here
(Image source)

pomsky
  • 68,507
0

An alternative is to use xkb but modify the /usr/share/X11/xkb/symbols/pc file.

(I found that adding an alias to /usr/share/X11/xkb/keycodes/evdev, as given in Rémy Hosseinkhan Boucher's answer, no longer works for me in Kubuntu 23.04 on a newer ThinkPad; meanwhile xmodmap changes can be autostarted on login, but do not persist after awaking the computer from sleep.)

First make a backup of the relevant file: sudo cp /usr/share/X11/xkb/symbols/pc /usr/share/X11/xkb/symbols/pc.backup

Then use your favorite text editor to change this line:

key <PRSC> {[ Print, Sys_Req ], type="PC_ALT_LEVEL2" };

to

key <PRSC> {[ Menu, Sys_Req ], type="PC_ALT_LEVEL2" };

Once the system is restarted PrtSc now functions as Menu.

N.b., the xkb package does change when you upgrade to a new version of Ubuntu, so the change will have to be reapplied then.

Fern Moss
  • 8,785