// packages/keyboard-shortcuts/src/context.js
import { createContext } from "@wordpress/element";
var globalShortcuts = /* @__PURE__ */ new Set();
var globalListener = (event) => {
  for (const keyboardShortcut of globalShortcuts) {
    keyboardShortcut(event);
  }
};
var context = createContext({
  add: (shortcut) => {
    if (globalShortcuts.size === 0) {
      document.addEventListener("keydown", globalListener);
    }
    globalShortcuts.add(shortcut);
  },
  delete: (shortcut) => {
    globalShortcuts.delete(shortcut);
    if (globalShortcuts.size === 0) {
      document.removeEventListener("keydown", globalListener);
    }
  }
});
context.displayName = "KeyboardShortcutsContext";
export {
  context
};
//# sourceMappingURL=context.mjs.map
