27

I'm using a PC keyboard on Mac OS. I can use the menubar to control the volume, but are there any keyboard shortcuts I can use to change the system volume?

Or perhaps a simple script or solution I can install to be able to set the volume using the keyboard.

6 Answers 6

21

You can buy the pro version of Sizzling Keys. It is a preference pane that allows you to define a custom keyboard shortcut for modifying system volume, among lots of other things.


Alternatively, you can modify system volume using AppleScript.

Open up AppleScript Editor and enter

set volume output volume 100

Volume is on a scale of 0 to 100. You can either set an absolute value (e.g. 100 for full volume), or create scripts that increase/decrease, such as the following:

set vol to output volume of (get volume settings)
if vol > 90 then # 100 max
    set volume output volume 100
else
    set volume output volume (vol + 10)
end if

For Volume Down:

set vol to output volume of (get volume settings)
if vol < 10 then # 0 is min
    set volume output volume 0
else
    set volume output volume (vol - 10)
end if

If you'd like to replicate the feedback sound that normally occurs when you change volume, you could add the following to the script:

    do shell script "afplay /System/Library/Sounds/Pop.aiff"

You can save scripts as these as applications, or integrate them into the Services menu using Automator as an input-less service. You can define keyboard shortcuts for services in System Preferences » Keyboard » Keyboard Shortcuts » Services

2
  • 3
    This was perfect. For those who haven't done it before: run Automator, File/New/Service, under Service receives selected choose "no input", on the left next to Variables search for "Run AppleScript" and double-click it, paste one of these scripts below where it says "your script goes here", click green run button to test it, save as "Volume Up" or "Volume Down", System Prefs/Keyboard/Shortcuts, select "Services" on the left, these should show up at the bottom where you can assign keyboard shortcuts. I had to run the services manually from the services menu once before the shortcuts worked.
    – nonagon
    Jun 13, 2014 at 18:44
  • 1
    After much trial, I found out that key assignments work outside Finder only if you set Full Keyboard Access to All controls May 12, 2016 at 10:38
14

Karabiner (formerly KeyRemap4MacBook) can remap function keys to control volume, and has been working seamlessly for me so far. In the control panel, search for "F9 to mute" etc.

2
  • It doesn't work if you don't have at least one keyboard (like the built-in keyboard of a laptop) that has the media keys. You can also map different keys to the media keys in private.xml.
    – Lri
    Feb 18, 2013 at 16:29
  • Works fine for me, good suggestion!
    – Fraukje
    Sep 18, 2014 at 15:54
8

I've packaged up a set of AppleScript services and instructions that let you control system & iTunes volume, as well as play/pause & next/prev on any keyboard in Lion.

http://gskinner.com/blog/archives/2011/10/media-keys-in-osx-for-any-keyboard.html

1
  • 1
    Welcome to Super User! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Oct 31, 2011 at 19:07
7

Old thread but the way I solved it is via a single line applescript based on other answers

Increase volume by 10%

osascript -e 'set volume output volume ((output volume of (get volume settings)) + 10)'

Decrease volume by 10%

osascript -e 'set volume output volume ((output volume of (get volume settings)) - 10)'

Actually ended up writing a blog post about using it with Alfred app: http://arif.im/system-volume-control-using-alfred/

2
  • Hi your blog post seems to be down (502 bad gateway) do you still host a cached copy? Sep 22, 2013 at 22:43
  • 1
    I've fixed the broken link. Check now. Nov 8, 2014 at 18:08
1

Here is my complete solution for shortcuts for volume up, down, and mute. I use the Spark application to bind key combinations to these scripts (http://www.macupdate.com/app/mac/14352/spark). The scripts check for the current mute state and handle it, so as to avoid weird problems that can happen if you don't properly control it.

Volume up:

set vol to output muted of (get volume settings)
if (vol = true) then
    set volume without output muted
end if
set vol to output volume of (get volume settings)
if vol > 95 then
    set volume output volume 100
else
    set volume output volume (vol + 5)
end if

do shell script "afplay /System/Library/Sounds/Pop.aiff"

Volume down:

set vol to output muted of (get volume settings)
if (vol = true) then
    error number -128
else
    set vol to output volume of (get volume settings)
    if vol < 5 then # 0 is min
        set volume with output muted
    else
        set volume output volume (vol - 5)
    end if

    do shell script "afplay /System/Library/Sounds/Pop.aiff"

end if

Mute/Unmute:

set vol to output muted of (get volume settings)
if (vol = true) then
    set volume without output muted
else
    set volume with output muted
end if
2
  • Welcome, and thanks for contributing on this question. For the benefit of readers who aren't familiar with scripts, could you add a couple of sentences to your answer explaining how to use the scripts?
    – fixer1234
    Dec 4, 2014 at 3:48
  • Oh I forgot that part. Done :) Dec 4, 2014 at 20:26
0

The F1 to F12 keys on the PC keyboard should do the same thing. I assume you have had no issues with substituting the "Windows" key for key. If the F1 to F12 keys don't work, go to system preferences,keyboard & mouse, keyboard and make the choices from there, whether to use the F keys directly or with the fn key qualifier. Regards Paul

1
  • 5
    PC keyboard, as in not usually equipped with an Fn key.
    – Daniel Beck
    Dec 21, 2010 at 8:10

You must log in to answer this question.

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