How to open context menu in (MacOS) Finder with keyboard

26

9

I'm sure most of us here like doing thing as efficiently as possible and therefore we're a bunch of keyboard junkies.

With a file (or group of files) highlighted, is there a way to open the context menu (equivalent of right-click) with the keyboard?

macek

Posted 2010-02-05T22:29:52.577

Reputation: 5 157

4

You may be better off learning or setting keyboard shortcuts for items in the regular menu bar, as the contextual menu likely is a subset of those actions. Apple Human Interface Guidelines state: Always ensure that contextual menu items are also available as menu commands. Therefore, I think it would be redundant to try to use a keyboard shortcut for the contextual menu. Having said that, people have tried various ways, with little success that I know of. http://forums.macosxhints.com/showthread.php?t=91915

– fideli – 2010-02-06T00:45:40.277

1

for completeness, the official list of finder shortcuts from Apple http://support.apple.com/kb/HT1343

– Jeff Atwood – 2010-02-06T09:59:01.540

Anyway to apply a color label via keyboard shortcut? – macek – 2010-02-08T19:10:10.023

Answers

18

Short answer: no.

Most items in the Finder’s context menu are already accessible via the menu bar & any thing in the menu bar is fair game for a custom keyboard shortcut in System Preferences (System Preferences > Keyboard > Keyboard Shortcuts > Application Shortcuts). You can assign keyboard shortcuts for most apps (Firefox excluded) in that panel and that includes the Finder. If it doesn’t immediately take effect, just relaunch the Finder.

A. L.

Posted 2010-02-05T22:29:52.577

Reputation: 103

1I'm really trying to apply a color label to specific folders and files with the keyboard. This is still useful information, thank you. – macek – 2010-02-08T19:07:10.040

The Preferences requests a 'Menu Title'. What's the 'Menu Title' for the 'context menu'? – AlikElzin-kilaka – 2012-11-22T10:08:38.960

7

Quicksilver proxy objects, specifically the "Current Selection" proxy object.

This will let you invoke Quicksilver with all of the items you have selected in the Finder as the thing you do stuff to.

I have a trigger (mine's set to ⌘+shift+space) set up to get all the currently-selected items in the Finder. The end result is that I can perform actions on the currently-selected items in the Finder with, like, three keystrokes. Most of the things I can do to the items are in the context menu, but not all, if I recall. Still, pretty handy.

Scott Jackson

Posted 2010-02-05T22:29:52.577

Reputation: 146

6

Not quite exactly the context menu, very close however. If you use the commands for Universal Access you can get to the menu for the Task button in the buttonbar.

Press control-F5 to put the focus on the buttonbar. Press tab until the Task button is highlighted, press space to open it, use the arrows to make your selection.

Note that you may have to enable Universal Access, and that you can change the control-F5 shortcut in the Keyboard prefpane. Also, the name of the button may be slightly different in English (I'm running in Dutch, and can't be bothered to switch languages to check the exact translation).

Johan Kool

Posted 2010-02-05T22:29:52.577

Reputation: 366

4

This answers the more specific question in your comment to your original question. It could probably have been a new question since it is much more specific.


To set the “Color Label” of the currently selected files, you can combine an AppleScript program (or a shell program that uses osascript) with any of the multitude of “launcher” applications (Quicksilver, FastScripts, etc.) that can run AppleScript programs (or shell programs) based on a shortcut key combination.

For any of the scripts below, paste them into Script Editor / AppleScript Editor and save them in “script” format (or whatever format your chosen launcher uses). The usual place for such saved scripts would be ~/Library/Scripts/Applications/Finder, but, depending on your launcher, you could use other locations.

Here is a simple version that you can hard-code to any one of the labels:

on run
    tell application "Finder"
        repeat with anItem in (get selection)
            (*
             * 0 - none
             * 1 - Orange
             * 2 - Red
             * 3 - Yellow
             * 4 - Blue
             * 5 - Purple
             * 6 - Green
             * 7 - Gray
             *)
            set label index of anItem to 4
        end repeat
    end tell
end run

If you only have a couple of labels that you use, you might save a couple of copies of this and bind a key to each copy.

Here is a version that always prompts you for which label to apply:

on run
    tell application "Finder" to set selectedItems to selection
    if length of selectedItems is 0 then
        display dialog "Select some items in Finder before running this program." with title "Apply Finder Label to Selected Items" buttons {"OK"} default button {"OK"}
        return
    end if

    set labels to prependIndicies(getLabelNames())
    set default to first item of labels
    set labelIndex to choose from list labels default items default with prompt "Choose label to apply to selected items" without empty selection allowed and multiple selections allowed
    if labelIndex is false then return
    set labelIndex to (first word of first item of labelIndex) as number

    tell application "Finder"
        repeat with anItem in selectedItems
            set label index of anItem to labelIndex
        end repeat
    end tell
end run

to getLabelNames()
    set labelNames to {"Orange", "Red", "Yellow", "Blue", "Purple", "Green", "Gray"}

    set useCustomLabelNames to true -- change to false if this is too slow or does not work for you
    if useCustomLabelNames then
        set cmds to {}
        repeat with i from 1 to 7
            set end of cmds to "defaults read com.apple.Labels Label_Name_" & (8 - i) & " || echo " & quoted form of item i of labelNames
        end repeat
        set text item delimiters to {";"}
        set labelNames to paragraphs of (do shell script (cmds as text))
    end if
end getLabelNames

to prependIndicies(theList)
    repeat with i from 1 to length of theList
        set item i of theList to (i as text) & " - " & (item i of theList)
    end repeat
    {"0 - none"} & theList
end prependIndicies

When the dialog appears, type one of 0-7 to select a label, then hit Return to apply it to the items selected in Finder.

Chris Johnsen

Posted 2010-02-05T22:29:52.577

Reputation: 31 786

You're right, this is nearly a whole separate question. I accepted the answer that targets the original question better, but I still voted this one one. I will give this a shot later tonight. Thanks, Chris :) – macek – 2010-02-09T19:21:11.637

1

The context menu can primarily be opened by a right mouse click only. But in the Universal Acces settings in the System Preferences we can control mouse keys by using the keyboard number pad. When activated, a right mouse click then can be achieved by Ctrl-5 on a keyboard with a numpad or Fn-Ctrl-I on a laptop. This will allow you to 'right-click' your word.

Go to System Preference --> Universal Access --> Mouse --> Enable Mouse Keys (ON)

Found on: https://stackoverflow.com/a/11238186/1919382

CousinCocaine

Posted 2010-02-05T22:29:52.577

Reputation: 129

I posted this answer on two similar questions, I do know the policy on this, but here are the sources: Ask different - OS X right click/context menu via keyboard and here Ask different - How do I open the context menu from a Mac keyboard?

– CousinCocaine – 2013-09-10T16:07:48.620

0

I do not know of a way to open the context menu for the current selection (which is what I think you really want) but you can “right click” whatever whatever is under the mouse pointer with only the keyboard.

Turning Sticky Keys and Mouse Keys on or off

Shortcuts for Mouse Keys

  • Activate Mouse Keys.
    • In System Preferences, search for “mouse keys” and turn it on.
      • You can also choose to have five presses of Option toggle Mouse Keys.
  • Position the mouse cursor.
  • Hold Control.
  • Press and release the keypad's 5 key (or Fn+I (not L, the one between U and O)).
  • Release Control.

But, this relies on having the mouse pointer properly positioned. If you have selected the files in Finder without using the mouse then the mouse pointer will likely be somewhere completely unrelated to your Finder task.

Chris Johnsen

Posted 2010-02-05T22:29:52.577

Reputation: 31 786

1I appreciate the help, but positioning the cursor defeats the purpose of a keyboard shortcut. I'm trying to SKIP the repeated slow task of targeting files with my mouse before I can right-click them. That is, files are already selected via keyboard, I don't want to target them twice. – macek – 2010-02-08T19:09:23.673