A macOS plugin which can register a callback for a global keyboard shortcut.

Last update: Jun 4, 2022

global_shortcuts

A macOS plugin which can register a callback for a global keyboard shortcut.

As the shortcut is global, the callback will be triggered even when the app does not have focus.

Installation

dependencies:
  global_shortcuts: any

Usage

Register a callback for a given ShortcutKey and zero or more ShortcutModifier

Future<void> register() async {
  try {
    await GlobalShortcuts.register(
      key: ShortcutKey.r,
      modifiers: [ShortcutModifier.shift, ShortcutModifier.command],
      onKeyCombo: _onKeyCombo,
    );
  } on Exception catch (_) {}
}

void _onKeyCombo() => print('Shortcut Pressed at ${DateTime.now()}');

Shortcut can be unregistered using

Future<void> unregister() async {
  try {
    await GlobalShortcuts.unregister();
  } on Exception catch (_) {}
}

Only one shortcut combo can be registered. If, for instance, CTRL+SPACE is registered after SHIFT+CMD+R, then the callback for SHIFT+CMD+R will no longer be invoked.

Notes

  • Presently the plugin only supports macOS. Windows support may be investigated, linux support is unlikely.
  • macOS plugin uses HotKey which does not seem to support all modifiers (i.e fn) while os global shortcuts like CMD+SPACE do not seem to be caught.
  • Due to 0.0.x versioning, package is presently experimental.

Collaboration

Spotted any problems? Please open an issue on GitHub! Would like to work on a windows or linux version? Fork the repo and submit a PR!

GitHub

https://github.com/defuncart/global_shortcuts
You might also like...

TinyPNG4Flutter - A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS and windows

TinyPNG4Flutter - A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS and windows

TinyPNG4Flutter A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS

Feb 9, 2022

Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device

Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device

Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device. One of Android-Toolbox's special feature is to transfer files at the highest speed using ADB push and pull bypassing a lot of Android API overheads.

Jun 9, 2022

A package which provides most of the window decorations from linux themes.

Window Decorations A package which provides most of the window decorations from linux themes. Features Easier to use and implement Native looking wind

May 14, 2022

Reversi Board with edax, which is the strongest reversi engine.

Reversi Board with edax, which is the strongest reversi engine.

pedax pedax is Board GUI with edax, which is the strongest reversi program. pedax has 4 features. Mac/Windows/Linux are supported. I distribute on Mac

Jan 26, 2022

Suwariyomi means to sit and read. Opposite of Tachiyomi which is to stand and read.

Suwariyomi Suwariyomi means to sit and read. Opposite of Tachiyomi which is to stand and read. Getting Started Install Android Studio (or any IDE you

Mar 24, 2022

A web dashboard that allows you to monitor your Chia farm and sends notifications when blocks are found and new plots are completed through a discord bot. It can link multiple farmers/harvesters to your account.

A web dashboard that allows you to monitor your Chia farm and sends notifications when blocks are found and new plots are completed through a discord bot. It can link multiple farmers/harvesters to your account.

farmr A web dashboard that allows you to monitor your Chia farm and sends notifications when blocks are found and new plots are completed through a di

May 26, 2022

Binder is a web framework that can be used to create web apps and APIs .

Binder is a web framework that can be used to create web apps and APIs .

Binder Framework Binder is a web framework that can be used to create web apps and APIs . It's like React + Express or any combination of front-end fr

Apr 19, 2022

Flutter plugin to store data behind biometric authentication (ie. fingerprint)

biometric_storage Encrypted file store, optionally secured by biometric lock for Android, iOS, MacOS and partial support for Linux, Windows and Web. M

Jun 20, 2022

A Flutter plugin to read 🔖 metadata of đŸŽĩ media files. Supports Windows, Linux & Android.

A Flutter plugin to read 🔖 metadata of đŸŽĩ media files. Supports Windows, Linux & Android.

flutter_media_metadata A Flutter plugin to read metadata of media files. A part of Harmonoid open source project 💜 Install Add in your pubspec.yaml.

Jun 28, 2022

Related

This plugin allows Flutter desktop apps to register and handle custom protocols

protocol_handler This plugin allows Flutter desktop apps to register and handle custom protocols (i.e. deep linking). English | įŽ€äŊ“中文 protocol_handler

Jun 16, 2022
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

May 27, 2022
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Jun 12, 2022
A cross-platform (Windows/macOS) scanner plugin for Flutter

quick_scanner A cross-platform (Windows/macOS) scanner plugin for Flutter Usage QuickScanner.startWatch(); var _scanners = await QuickScanner.getScan

Jun 10, 2022
A Dart/Flutter package to register/query/remove URI Schemes without hassle.

protocol_registry Register/query/remove URI Schemes without hassle. Available for Windows and Linux. Installation flutter pub add protocol_registry Us

Feb 14, 2022
🎞 Flutter media playback, broadcast & recording library for Windows, Linux & macOS. Written in C++ using libVLC & libVLC++. (Both audio & video)
🎞 Flutter media playback, broadcast & recording library for Windows, Linux & macOS. Written in C++ using libVLC & libVLC++. (Both audio & video)

dart_vlc Flutter media playback, broadcast, recording & chromecast library for Windows, Linux & macOS. Written in C++ using libVLC & libVLC++. Install

Jun 19, 2022
Flutter widgets and themes implementing the current macOS design language.
Flutter widgets and themes implementing the current macOS design language.

macos_ui Flutter widgets and themes implementing the current macOS design language. NOTE: This package depends on the excellent native_context_menu pl

Jun 24, 2022
A cross-platform app ecosystem, bringing iMessage to Android, PC (Windows, Linux, & even macOS), and Web!

BlueBubbles Android App BlueBubbles is an open-source and cross-platform ecosystem of apps aimed to bring iMessage to Android, Windows, Linux, and mor

Jun 24, 2022
Simple file explorer for desktop made with Flutter, highly inspired by macOS Finder

file_explorer A basic file explorer made with Flutter Getting Started This project is a starting point for a Flutter application. A few resources to g

Nov 7, 2021
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

go-flutter - A package that brings Flutter to the desktop Purpose Flutter allows you to build beautiful native apps on iOS and Android from a single c

Jun 27, 2022