53

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.

4
  • 3
    the key between right Alt + right Ctrl? – hytromo Aug 1 '12 at 11:49
  • 3
    I think this would work if I had a full windows keyboard, but sadly I am limited to the keys provided on a MacBook. – Bill Cheatham Aug 1 '12 at 16:04
  • You are using Ubuntu but ultimately it is MacBook Pro. – d a i s y Jan 20 '17 at 10:35
  • @daisy Which does not necessarily make it offtopic, or otherwise. They are asking how to get a keyboard shortcut that would have the effect of a right click, which is still on topic and such. – Thomas Ward Jan 20 '17 at 15:16
52

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).

4
  • Thanks! I can confirm this works on a thinkpad T440 ubuntu 16.04 – sunew Sep 4 '18 at 16:43
  • 2
    Does not have the same effect as right-clicking a specific location! – vanadium Jun 15 '19 at 15:12
  • Works in Thinkpad E470 on Ubuntu 16.04 – vineeshvs Nov 17 '19 at 9:23
  • Works like a charm on ubuntu 19.10 – Elouan Keryell-Even Jan 21 '20 at 9:39
21

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
5
  • 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 3: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 2: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 7 at 8:53
10

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

4
  • Thanks, but I'm not getting any luck with this! Maybe your OSX might be doing this interpretation rather than the Linux itself. – Bill Cheatham Aug 20 '12 at 5:35
  • This worked on my MacBook Air running Ubuntu 10.04. Thanks! – Waldir Leoncio Jul 15 '14 at 22:58
  • It works on ubuntu 14.04(Dell) too. – blackfyre Jun 15 '15 at 17:04
  • Does not have the same effect as right-clicking a specific location! – vanadium Jun 15 '19 at 15:12
5

I generally use the basic: Ctrl+F10

1
  • 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 6:37
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.

0
2

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

1
  • Does not have the same effect as right-clicking a specific location! – vanadium Jun 15 '19 at 15: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.

2
  • My MacBook keyboard has two alt keys. And the cmd keys act as Super keys like windows keys. – jarno Jul 27 '18 at 11:28
  • xdotool click 3 does the trick. See my answer. – jarno Jul 27 '18 at 11:34
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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.