Create functional volume keys for keyboards

Nov 10, '05 06:30:00AM

Contributed by: hisbonenus

I couldn't find this covered, and it's fairly simple, but I didn't see any references to it elsewhere, either. I recently bought a Kensington keyboard to replace my broken Apple keyboard -- I figured it was worth saving a few dollars. Then I realized that it would be awfully hard to live without my volume adjustment keys! Enter AppleScript and Xkeys.

I simply mapped AppleScripts that adjust the volume (up, down, and mute; courtesy of a Google search) to function keys F13 - F15. Voila! Works exactly like my other keyboard!

[robg adds: Though the author offered to share his scripts, I figured I'd just list three that worked; these may differ from those of the author, but I tested them and they work...

Volume Up:

set volume output volume ((output volume of (get volume settings)) + 3)
Volume Down:
set volume output volume ((output volume of (get volume settings)) - 3)
In both of the above, feel free to change the 3 to another value; go outside +3 or -3, and the volume change per key press increases; go the other way to reduce the step size.

Toggle Mute:
if output muted of (get volume settings) then
  set volume without output muted
else
  set volume with output muted
end if
Though they were tested, I didn't actually use Xkeys to assign them, but I wouldn't expect any issues...]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20051107024046848