Skip to content

Can't register media keys on macOS with system scope #62

Description

@aluedtke7

When I register a media key like PhysicalKeyboardKey.mediaPlayPause with system scope, I get the error:

Could not cast value of type 'NSNull' (0x14e87f280) to 'NSNumber' (0x1f459cdd8).

and the app terminates. I can register such keys with the scope inapp without a crash, but then I don't get any events in the keyDownHandler or keyUpHandler. On the other side, I'm able to register i.e. a hotkey for F9 with system scope that does work as expected.

When I use LogicalKeyboardKey.mediaPlayPause instead, the behavior and error message is the same (only the value of NSNull is slightly different).

Please let me know if further details are needed.

HotKey playPauseHK = HotKey(key: PhysicalKeyboardKey.mediaPlayPause, modifiers: [], scope: HotKeyScope.system);

await hotKeyManager.register(
  playPauseHK,
  keyDownHandler: (key) {
    debugPrint('PlayPause down: ${key.toJson()}');
  },
  keyUpHandler: (key) {
    debugPrint('PlayPause up: ${key.toJson()}');
  },
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions