74

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

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 need 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

10 Answers 10

21

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.

| improve this answer | |
  • 20
    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
  • 2
    @ArnoldRoa Agreed. Any way to do this at the current selection or cursor position not the mouse location? – J Spen Oct 12 '16 at 14:53
  • @ArnoldRoa @J Any luck with this? – Doug Jun 17 '19 at 9:51
11

For difficulties using the mouse, you can turn on Mouse Keys: Located in System Preferences > Universal Access > Mouse tab.

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:

| improve this answer | |
  • 1
    I can't find. my os ver is 10.8.5, which is yours? – preetam Feb 3 '14 at 11:24
  • 3
    The Universal Access preference pane has been called Accessibility since 10.8. – Lri Feb 3 '14 at 19:07
  • @Nixx: I am able to use keyboard for navigation of mouse pointer only. However option key is not working and thats my requirement – preetam Feb 4 '14 at 12:41
7

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.

| improve this answer | |
  • couldn't find this option, using macbook, without mouse – preetam Oct 25 '16 at 6:10
  • It works! but its useless, cause I must have mac's Fn key around to do it. and if I have it around, it means I'm working on the actual laptop, meaning I would probably use the trackpad. it's for the times where I'm using external keyboard that this functionality becomes handy. only that I couldn't find a way to map my Windows-Option key on my HP keyboard, to the Fn key. – kumetix Oct 25 '16 at 12:43
  • @preetam - What version are you using? – airsquared Oct 25 '16 at 15:07
  • 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
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

| improve this answer | |
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.

| improve this answer | |
  • 4
    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 6 '17 at 9: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.

| improve this answer | |
  • I didn't even tried as it looks weird to install some third party tools and apple didn't provide this simple. – preetam Oct 30 '18 at 8:30
0

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!

| improve this answer | |
-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

| improve this answer | |
  • 1
    it may select/activate, but its not making "right click". – preetam Oct 25 '16 at 6: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 8:28
-3

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.

| improve this answer | |
  • 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
-4

You need to use -> Option key.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .