113

Is there way to set a keyboard shortcut or key to simulate a mouse right click but without touching trackpad or mouse?

Specifically, I am interested in the right click happening away from where the mouse / pointer are located, so it’s different than just a proper right click at the pointer location.

E.g. Imagine you have a list of files in Finder. You move your selection by going up and down with keyboard arrows. When you are happy with selection, you "press a button" and it simulates as if you did a secondary click on the file you selected earlier with the keyboard. The context menu should not open where the mouse pointer is, otherwise I'd have to move it over selection first, which ruins the keyboard-only workflow.

On Mac currently, all current right click options requires me to touch trackpad or mouse:

  • Two finger single tap

  • CTRL+click

  • Tap in right area of trackpad if enabled in Trackpad Settings.

Similar to following windows option key.

enter image description here

11 Answers11

26

I don't know any way to show a context menu for items selected with the keyboard like what the menu key does in Windows.

To assign a keyboard shortcut for performing a secondary click at the current coordinates of the pointer, you can either:

  • Use a private.xml like this with Karabiner:

    <?xml version="1.0"?>
    <root>
      <item>
        <name>Right Mousebutton</name>
        <identifier>rightMouseButton</identifier>
        <autogen>__KeyToKey__ KeyCode::OPTION_R, PointingButton::RIGHT</autogen>
      </item>
    </root>
    
  • Use BetterTouchTool:

  • Use Keyboard Maestro:

  • Download MouseTools and assign a shortcut to MouseTools -rightClick.

James
  • 103
Lri
  • 105,117
  • 36
    There is no point in do it at current mouse coordinates.. it should be a current selection.. is possible? – Arnold Roa Feb 13 '16 at 12:33
14

For difficulties using the mouse, you can turn on Mouse Keys: Located in System Preferences > Universal Access > Mouse tab. (Newer macOS call this Accessability)

As it states "Use the Keyboard in place of the mouse". Also several options are available to choose from that may meet your needs.

Apple's support notes for each OSX version have more information:

bmike
  • 235,889
Nixx
  • 141
  • 1
    @Nixx: I am able to use keyboard for navigation of mouse pointer only. However option key is not working and thats my requirement – Preetam Jadakar Feb 04 '14 at 12:41
9

If you can't enable it in the first method, use the second method.

Method 1

Go to System Preferences > Accessibility, find Mouse & Trackpad, then enable "Mouse Keys". If you want, go to the options menu and enable "Press the Option key five times to toggle Mouse Keys".

System Preferences

Method 2

Press Option-Command-F5, and a window will pop up. Select "Enable Mouse Keys".

Accessibility Options

How to use Mouse Keys

To right click press Fn-Ctrl-I. Sometimes you might want to turn Mouse Keys off as some keys on your keyboard won't function properly. If you are using an external keyboard, just find the equivalent to the function key. To map keys on a Windows keyboard with a Mac, visit this guide.

airsquared
  • 5,107
  • 2
    Without a number keypad, the "some keys" that won't work under Mousekeys are 7, 8, 9, U, O, J, K, L, which could be a problem... – Tom Gewecke Oct 25 '16 at 15:39
  • 1
    @TomGewecke I know, that's why I showed how to quickly activate and deactivate mouse keys/ – airsquared Oct 25 '16 at 23:37
  • @books453: enabling mouse key is really weird, have you tried working after enabling? btw, its giving right click on mouse position, that should not be the case. – Preetam Jadakar Oct 26 '16 at 05:50
  • 1
    There is no point in doing it at current mouse coordinates.. it should be a current selection... – genericUser Dec 13 '22 at 15:36
4

There is some builtin feature you can access by System Preferences -> Keyboard -> Shortcuts -> Keyboard (sorry I have the german OS X installed so this is my rough translation).

There you can find a keyboard shortcut called "Focus to menubar" (my shortcut is set to CTRL-F2.

Activate it, select the file and hit the shortcut keys, then you get the keyboard focus on your menubar. Navigate with the cursor keys to the "Services" menu, select the service and hit Enter.

Voila, the service is executed on the selected file

Martin Allert
  • 948
  • 4
  • 8
3

I've been looking for a solution to this for years! I finally chanced upon this RightClick Alfred workflow which does what I was looking for. It looks like it can also be installed as a Finder service.

The Alfred workflow works for me on 10.15.5 Catalina, though it does take around 0.5s to pull up the right-click menu. I've validated this works in Notes and Finder, though it may work in other apps too. Note that this pulls up the right-click menu at the location of the selection (which is what most people want), not the location of the mouse pointer.

workflow settings

P.S. I had to create an account and answer some other people's random questions just to build up the reputation to post this response - hope it helps others!

sdlynx
  • 47
2

Here's a solution using Automator and Python. It's a bit slower than a real mouse (~0.5 second delay), but it works and requires no third-party software.


Open Automator and create a new service:

Automator service menu


Choose Service receives no input in any application .

Search for "shell" and drag the "Run Shell Script" action to the storyboard:

Storyboard


Paste the following code into the Run Shell Script action:

from Quartz.CoreGraphics import CGEventCreateMouseEvent, kCGMouseButtonRight, CGEventPost, kCGHIDEventTap, CGEventCreate, kCGEventRightMouseDown, kCGEventRightMouseUp, CGEventGetLocation

def mouseEvent(type, posx, posy):
          theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonRight)
          CGEventPost(kCGHIDEventTap, theEvent)

event = CGEventCreate(None)
position = CGEventGetLocation(event)
mouseEvent(kCGEventRightMouseDown, int(position.x), int(position.y))
mouseEvent(kCGEventRightMouseUp, int(position.x), int(position.y))

Save the service (cmd+s). Use a descriptive name like "Perform a right-click".


Go to System Preferences → Keyboard → Shortcuts → Services.

The services menu

Look for your service (it should be near the bottom of the list) and assign a keyboard shortcut.

You should now be able to use your shortcut to perform a right-click.

SomeDude
  • 476
  • 7
    The problem with this solution is that the click happens exactly where the mouse is. So if you are scrolling items with the arrow keys (like the desktop icons say) and then use the shortcut the popup will not show the icon properties but the properties of the item your mouse is currently on... – Manfredo Jun 06 '17 at 09:16
0

I am on High Sierra 10.13.2. could not install Karabiner, and Keyboard Maestro provides click only for the given location (did not try to find cursor point and refer it). Installed Shortcat and seems fine so far, also Vimium is super useful, but works only in browsers.

grg
  • 201,078
mtn
  • 1
-1

Here's a close keyboard replica for right clicking for context menus: ⌘ command+shift+/

This places the key caret in the the menu search box, then you may type to find the command you wanted to click in the context menu.

To execute the command when it appears below the input box: ⬇ arrow+return

Putting this together for the example case of selecting "open" in the context menu when right-clicking a file in Finder: ⌘ command+shift+/ OPEN ⬇ arrow+return

nsolent
  • 109
  • do you really understand the question or what has been asked? – Preetam Jadakar Mar 02 '23 at 04:00
  • Yes. Updated my answer with example matching your e.g. in your question. You don't state which command you want to click so I applied to "open" but you could "get info" or "compress" — just type command in the menu search. Try it! – nsolent Mar 03 '23 at 07:13
-2

Tab to the link or item and either press return or the space bar to select and activate, then press return. enter image description here

Tunes
  • 198
  • 9
  • 1
    it may select/activate, but its not making "right click". – Preetam Jadakar Oct 25 '16 at 06:08
  • I see what you mean. The challenge for lifelong mac users is knowing how to answer this question without more info about your end goal. One of the things I loved when I was using Windows was that nearly everything had a keyboard shortcut or a way to use the keyboard to execute an action. What is the command you are trying to execute with the right-click? – Tunes Mar 10 '17 at 08:28
-4

In Mojave, simply two finger click on the trackpad will generate right click effect, such as spell check over red squiggly lines words on text to correct the spelling.

  • 1
    The target of the question is to use the keyboard only because a mouse or a trackpad are too slow (for some of us used to type fast). – dan Aug 11 '19 at 12:09
-5

You need to use -> Option key.