63

I am looking for a keyboard shortcut to raise a context menu using Ubuntu on a MacBook pro. Pressing the keyboard shortcut should have the same effect as right-clicking at the cursor location.

On Windows keyboards, there is a dedicated button for this near the space bar. I have also read about using Shift+F10 or Ctrl+Space, but these have no effect on my system.

A.B.
  • 89,123
  • 21
  • 245
  • 323
Bill Cheatham
  • 1,082
  • 4
  • 14
  • 21

9 Answers9

68

Shift+F10 worked in my case. I guess the need of Fn depends on the keyboard you are using.

P.S. I used this combination on a file in Nautilus (Ubuntu 14.04 LTS).

Fabby
  • 34,341
  • 38
  • 97
  • 191
curi0us-m0nkey
  • 922
  • 9
  • 11
32

The keysym to trigger the context menu is called Menu. It can be bound to an arbitrary keycode like this:

$ xmodmap -e 'keycode 68 = Menu'

Can be manually triggered from the command line like:

$ xdotool key Menu

And to find out the keycode it is currently bound to one can do:

$ xmodmap -pke | grep Menu

To figure out what keycode a key emits one can use:

$ xev
Grumbel
  • 4,679
  • 6
  • 35
  • 51
  • I think this is the best option since modern keyboards have removed the context key, unfortunately. I used keycode 105 which is my right control key. – Miladiouss Apr 18 '18 at 03:46
  • +1 this is the correct answer - by default in MATE, gnome shift+f10 will work but whatever window manager you use they all end up executing that command. Also this explains how this can be configurable - for example, if in your system doesnt work, look for key bindings configuration and link whatever keys you want with that command and voila. thanks – cancerbero Oct 25 '18 at 02:26
  • Does not have the same effect as right-clicking a specific location! – vanadium Jun 15 '19 at 15:12
  • I don't have a Menu key, so with the information from this answer I managed to map my right `Alt` key to Menu with: `xmodmap -e 'keycode 108 = Menu'`. So great! Now I can use my mouse less often :) – 7ochem Jul 24 '20 at 19:53
  • It worked, thank you. I've assigned right Alt, but now it is not possible to use it in traditional Alt combination. Is it possible to fix it? – Dmitriy Vinokurov Feb 07 '21 at 08:53
  • I used right "Start" key (Super_R or 134). Where would be a good place to put `xmodmap -e 'keycode 134 = Menu'` ? `~/.profile` ? (putting it in `~/.Xmodmap` yields syntax error – Michał Lepczyński Oct 21 '22 at 23:31
10

Try Shift+Fn+F10. This works on Windows and Ubuntu in VirtualBox on OS X for me.

curi0us-m0nkey
  • 922
  • 9
  • 11
pratnala
  • 729
  • 3
  • 13
  • 32
4

Make sure you have a package named xdotool installed.

Make this application shortcut for the key of your preference:

xdotool click 3

Unfortunately this does not work on some applications, but seems to work on chromium-browser and firefox.

Bonus: For middle click the command is

xdotool click 2

Making application shortcuts for keyboard may vary according to the desktop environment used. In Xfce (used in e.g. Xubuntu) making such shortcuts happens easily in Keyboard dialog.

jarno
  • 5,317
  • 5
  • 49
  • 77
4

I generally use the basic: Ctrl+F10

Sooth
  • 141
  • 1
  • 2
  • 2
    In nautilus, using Ctrl+F10 would be the same as Shift+F10 (adding Fn if necessary) **unless** an item is selected, in which case Shift+F10 opens the context-sensitive right-click menu for that specific item. For example, Ctrl+F10 will always say "New Folder", regardless. But if a file "foo.txt" is selected, Shift+F10 opens a menu with (for example) "Open with GVim"; or, if "foo.mp4" is selected, the menu might say "Open with VLC". – michael Jun 24 '16 at 06:37
3

Some combination of: (shiftorctrl)+(F10orFnF10), the shifts and ctrls on the left of the keyboard should be used.

If you want the application context menu in Raspbian Pi Linux: alt+space

Context key sometimes works: context key button on some keyboards it is the one with the list and mouse pointer

xxjjnn
  • 1,727
  • 2
  • 13
  • 12
1

My solution was to find an old 2-button mouse and plug it in.

I tried all the answers I saw above. Most seem to ignore part of the problem, which is that mac keyboards do not have alt or the windows key, in addition to the mouse not having two or more buttons.

I also did not understand what they expected the cursor/mouse to be doing while you hit shift-f10 or whatever. I want to lock an icon to the launcher, there is no way to select it first and then hit some key sequence. I can hover over it, or I can left-click it. Left-click and hold, then key sequnce while holding? Doesn't seem to work.

The answer above with xmodmap and xev commands seems like it might point in the right direction. But It's more like a "the solution exists" rather than an actual solution. Which key can I remap without messing things up? Shift-f10 seems to do nothing now, how would I use xmodmap to map menu to shift-f10? At least it provides a place to start the web search.

Also, the menu that comes up when I invoke "xdotool key menu" while hovering the mouse over something is not the same menu that comes up when I right-click on the same item. So "menu" is not quite what the OP asked for.

Dave
  • 11
  • 1
0

On my system (Ubuntu 18.04):

$ xmodmap -pke | grep Menu
keycode 135 = Menu NoSymbol Menu NoSymbol Menu

This is a Lenovo laptop. The laptop's built-in keyboard has a meny key between Right AltGr and Right Ctrl that triggers the context menu. A Logitech external keyboard that I use does not have a separate menu key. On that keyboard the combination Fn+Right Ctrl triggers the context menu.

codeape
  • 657
  • 9
  • 24
0

The keybinding for Mac is CTRL+SPACE. This should open the right click or "context menu".

For linux, the combo is supposed to be CTRL+F10 and as stated, you may need to toggle or hold down the fn key as well.

However, you have mentioned, this does not work.

So, you may need to use the set keybinding for Mac instead as you are running linux on a Mac instead of a PC.

Click here for more info and a more complete list of keybindings.

mchid
  • 42,315
  • 7
  • 94
  • 147