Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 1.13 KB

README.md

File metadata and controls

29 lines (19 loc) · 1.13 KB

NuGet Status

HotkeyManager.Binding

Xamarin binding for the JFHotkeyManager

JFHotkeyManager is a small Cocoa convenience wrapper around Carbon's mechanism for implementing global hotkeys. It allows you to add hotkeys to your app with a couple of lines of code.

Usage

Hotkeys can be bound either by individually specifying keycode/modifiers, or symbolically using a string. The latter is more convenient but probably less reliable across international keyboards.

// Initialise a new hotkey manager
var hotkeyManager = new JFHotkeyManager();
            
// Bind a hotkey by key code reference number and modifiers:
hotkeyManager.BindKeyRef(49, (uint)(EModifierKeys.CmdKey | EModifierKeys.ShiftKey), this, new ObjCRuntime.Selector("onHotkeyExecuted"));
            
// Bind a hotkey symbolically
hotkeyManager.Bind("command shift up", this, new ObjCRuntime.Selector("onHotkeyExecuted"));

[Export("onHotkeyExecuted")]
void OnHotkeyExecuted()
{
  // do something
}