3

I am trying to edit the behavior of the media key "<<" on a macbook keyboard. There is a way to map the "rewind" button to the "short jump back" function in vlc? How does mac os deal with media keys under the hood?

2 Answers 2

1

Actually mapping any key in a specific application is built into macOS.

system preferences > keyboard > shortcuts > App shortcut

Once you are there click the + and select VLC from the Application menu at the top, then type in the EXACT menu name. Exact is important it has to be capitalized correctly and if it has "..." at the end remember that is not three periods its an ellipsis which you get by pressing Option;. Then click in the Keyboard Shortcut field and tap the key you want to assign. In your case that would be F7.

This can generally be done for any Application that does not have a keyboard shortcut already assigned. If there is one already assigned you may have to remove that first.

0

What didn't work

I had the same need but was unable assign a shortcut to the "<<" media key using System Preferences. When I pressed the key at the Keyboard Shortcut input it didn't take, but instead rewound VLC. I was also unable to remap the "rewind" key using Karabiner Elements (13.5.0 on Big Sur) to something I could make a shortcut with.

Alternative

Since I was unable to use "rewind", instead I built up a solution which uses normal F7 (otherwise the "<<" media key), F8, and F9 function keys to trigger Step Backward, Play/Pause, and Step Forward. You can use other keys (see below).

Background

As described in this videolan forum thread VLC provides an AppleScript "dictionary" which can be used to automate it, including play to toggle play/plause, step backward N, and step forward N. Here is a simple example:

tell application "VLC" to step backward 1

AppleScript can be invoked in many ways on a Mac, including by making an app and assigning a keyboard shortcut to call the app as a Service.

My solution

However, I was already using Hammerspoon for other shortcuts and it can call AppleScript directly. Here are the bindings I created to get the F-keys to work:

hs.hotkey.bind("", "F7", function()
  hs.osascript.applescript("tell application \"VLC\" to step backward 1")
end)
hs.hotkey.bind("", "F8", function()
  hs.osascript.applescript("tell application \"VLC\" to play")
end)
hs.hotkey.bind("", "F9", function()
  hs.osascript.applescript("tell application \"VLC\" to step forward 1")
end)

Before you invest in Hammerspoon, you can install it and use its Console to first test that it will work to control VLC with this: hs.osascript.applescript("tell application \"VLC\" to step backward 1")


Bonus

Since I already gave up using the media keys themselves, I created Hammerspoon shortcuts which worked better from within my editor to control VLC playback, making it easy to transcribe without lifting my fingers from the home row: Control + Shift + j for step backward 1 etc.

hs.hotkey.bind("ctrl shift", "j", function()
  hs.osascript.applescript("tell application \"VLC\" to step backward 1")
end)

I also followed that videolan thread to Mac for Translators and a way to insert the current time code playing in VLC into your editor or clipboard. Transcription with VLC is so easy now. I'll have to try it with audio too.

You must log in to answer this question.

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