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

16,592

Solution 1

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.

Solution 2

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.

Solution 3

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

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

Solution 5

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.

Share:
16,592

Related videos on Youtube

macek
Author by

macek

Updated on September 17, 2022

Comments

  • macek
    macek almost 2 years

    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?

    • fideli
      fideli over 14 years
      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. forums.macosxhints.com/showthread.php?t=91915
    • fideli
      fideli over 14 years
    • Jeff Atwood
      Jeff Atwood over 14 years
      for completeness, the official list of finder shortcuts from Apple support.apple.com/kb/HT1343
    • macek
      macek over 14 years
      Anyway to apply a color label via keyboard shortcut?
  • macek
    macek over 14 years
    I'm really trying to apply a color label to specific folders and files with the keyboard. This is still useful information, thank you.
  • macek
    macek over 14 years
    I 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
    macek over 14 years
    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 :)
  • AlikElzin-kilaka
    AlikElzin-kilaka over 11 years
    The Preferences requests a 'Menu Title'. What's the 'Menu Title' for the 'context menu'?
  • CousinCocaine
    CousinCocaine almost 11 years
    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?
  • Admin
    Admin about 4 years
    Whatever happened to ctrl-click?
  • Tom
    Tom about 3 years
    This doesn't work with Open With (at least for me, on 11.4) – it simply shows the File menu, highlighting where Open With is, but I still can't invoke the functionality without the mouse.
  • Tom
    Tom about 3 years
    This doesn't work for Open With (at least for me, on 11.4): when looking at the File menu I do see that Open With has been assigned the shortcut key I chose, but still nothing happens when I press it (well, not nothing: the File menu title is highlighted momentarily. But the Open With menu is not opened).
  • BarathVutukuri
    BarathVutukuri about 3 years
    @Tom Could you tell me what are you trying to open and in which application? I'm on 11.2 and it works for me. I'm in finder and a image is selected. With the above combination help window opens and if I type preview and hit enter, the file opens in preview.
  • Tom
    Tom about 3 years
    You're right! I was hoping to just type "open with" and to get the Open With menu, and this didn't work. But I don't actually need the Open With menu - I get all the sub-options in the help menu already, and can open what I need from there!
  • Tom
    Tom about 3 years
    Just to update that currently (11.4) Universal Access is called Accessibility and the relevant options are there under Pointer Control.
  • Tom
    Tom about 3 years
    Just to update that this is currently (11.4) under Universal AccessPointer Control.