27

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?

studiohack
  • 13,477
macek
  • 6,525

9 Answers9

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.
  • 153
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.

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

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
  • 42,029
2

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

1

Cmd + Shift + / will invoke the help menu at the Menu bar. If you're aware of the item name in context menu, you can type it there and hit enter when appropriate entry is highlighted.

1

Expanding to @JohannKool's answer, it helps to reorganize the toolbar. Making the Action item to be the first item in Finder toolbar, one gets instant access to it by just pressing Control + F5 once.

  • If the Finder toolbars are hidden, first activate them by choosing View > Show Toolbar from the Finder menu or press Option + Command + T.

  • To place the Action item to the beginning of the toolbar, choose View > Customize Toolbar

    Customize Toolbar

  • Drag the Action item to the frontmost position. To rearrange items, one may need to press and hold the Command key while dragging.

    Drag Action item to be the first item

  • Back inside a Finder window, select a file and press Control + F5 to activate the Action item in Finder toolbar. Then use Arrow keys to navigate through Action item menu. Navigate with Arrow down to a sub menu like Open With and then use Arrow right to enter the submenu. Arrow left gets one back to Action item main menu. By pressing Enter, a menu item is getting executed, e.g. opening the selected Finder item(s) in a non standard app. To leave the Action item menu, just press Esc key.

    Action item menu is similar to Context menu

  • If this doesn't work, check System preferences > Keyboard > Shortcuts > Keyboard. Move focus to the window toolbar Control + F5 needs to be selected and Full keyboard Access needs to be set to All controls.

    Configure System Preferences to make this shortcut work

  • Finally in System preferences > Keyboard > Keyboard, there is an option to press fn key for accessing standard Function keys like F5 or not. This means, the shortcut for accessing Action item Control + F5, could possibly be Control + F5 + fn for some users. That shortcut can also be setup to one's liking, e.g. without a Function key. This comes in handy, especially if no real Function keys are present on Touch Bar Macs anymore.

Although this won't activate the real Context menu by keyboard shortcuts, Action item should contain the desired functionality, too. This is tested to work on OS X 10.9.x through macOS 10.14.x.

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
  • 42,029
0

On MacOS Sequoia, Control-Enter brings up the context menu.