@gphone/sdk
    Preparing search index...

    Function useKeybinds

    • OS Service Hook for keyboard shortcuts.

      An app claims an action while it is mounted and the shell routes the key to it, so App.svelte never needs to know which apps exist or what keys they want — the same reason every other OS service goes through the SDK.

      const { onKeybind } = useKeybinds();
      onKeybind('shutter', takePhoto);

      Returns {
          bindings: Readable<Record<string, string>>;
          findConflict: (actionId: string, key: string) => KeybindAction | undefined;
          groups: Readable<KeybindGroup[]>;
          onKeybind: (
              actionId: string,
              handler: () => void,
              appId?: string,
          ) => () => void;
          resetBindings: () => void;
          setBinding: (actionId: string, key: string) => void;
      }

      • bindings: Readable<Record<string, string>>

        Live map of actionId -> bound key.

      • findConflict: (actionId: string, key: string) => KeybindAction | undefined

        The action already using this key in the same context, if any. Two actions may share a key when their contexts are disjoint — Enter is both Answer Call and the camera shutter, and only one is ever eligible.

      • groups: Readable<KeybindGroup[]>

        Everything configurable from gPhone's own Shortcuts screen, grouped by owner.

        Core first (ownerId: 'core'), then one group per installed app that declares its own keybinds, sorted alphabetically by ownerLabel. An app with no declared keybinds contributes no group at all, rather than an empty one.

      • onKeybind: (actionId: string, handler: () => void, appId?: string) => () => void

        Claim an action for as long as this component is mounted.

        Pass appId for anything an app claims. Apps are resident, so the claim outlives the app being on screen, and without an owner the dispatcher hands the action to whichever app registered last — see the registry note in shell/state/keybinds.ts. Only actions carrying their own when: 'app:…' context are safe without it, and naming the app costs nothing either way.

      • resetBindings: () => void
      • setBinding: (actionId: string, key: string) => void