A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
/* Copyright 2026 Marimo. All rights reserved. */
import { atom, useAtomValue, useSetAtom } from "jotai";
import useEvent from "react-use-event-hook";
import type { HotkeyAction } from "@/core/hotkeys/hotkeys";
import { Objects } from "@/utils/objects";
/**
* Map of registered keyboard shortcuts and their callbacks.
*/
const registeredActionsAtom = atom<
Partial<Record<HotkeyAction, (() => void) | undefined>>
>({});
/**
* Returns the map of registered keyboard shortcuts and their callbacks.
*/
export function useRegisteredActions() {
return useAtomValue(registeredActionsAtom);
}
/**
* Returns a hook for registering keyboard shortcuts.
*/
export function useSetRegisteredAction() {
const set = useSetAtom(registeredActionsAtom);
return {
registerAction: useEvent(
(shortcut: HotkeyAction, callback: (evt?: KeyboardEvent) => void) => {
set((actions) => ({ ...actions, [shortcut]: callback }));
},
),
unregisterAction: useEvent((shortcut: HotkeyAction) => {
set((actions) => Objects.omit(actions, [shortcut]));
}),
};
}