MCPcopy
hub / github.com/claude-code-best/claude-code / useShortcutDisplay

Function useShortcutDisplay

src/keybindings/useShortcutDisplay.ts:29–59  ·  view source on GitHub ↗
(
  action: string,
  context: KeybindingContextName,
  fallback: string,
)

Source from the content-addressed store, hash-verified

27 * // Returns the user's configured binding, or 'ctrl+o' as default
28 */
29export function useShortcutDisplay(
30 action: string,
31 context: KeybindingContextName,
32 fallback: string,
33): string {
34 const keybindingContext = useOptionalKeybindingContext()
35 const resolved = keybindingContext?.getDisplayText(action, context)
36 const isFallback = resolved === undefined
37 const reason = keybindingContext ? 'action_not_found' : 'no_context'
38
39 // Log fallback usage once per mount (not on every render) to avoid
40 // flooding analytics with events from frequent re-renders.
41 const hasLoggedRef = useRef(false)
42 useEffect(() => {
43 if (isFallback && !hasLoggedRef.current) {
44 hasLoggedRef.current = true
45 logEvent('tengu_keybinding_fallback_used', {
46 action:
47 action as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
48 context:
49 context as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
50 fallback:
51 fallback as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
52 reason:
53 reason as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
54 })
55 }
56 }, [isFallback, action, context, fallback, reason])
57
58 return isFallback ? fallback : resolved
59}

Callers 15

TaskOutputResultDisplayFunction · 0.85
BackgroundHintFunction · 0.85
ResumeTaskFunction · 0.85
SessionBackgroundHintFunction · 0.85
ConfigurableShortcutHintFunction · 0.85
CtrlOToExpandFunction · 0.85
ThemePickerFunction · 0.85
MessagesImplFunction · 0.85
HelpV2Function · 0.85
DiffDialogFunction · 0.85
CompactBoundaryMessageFunction · 0.85

Calls 2

logEventFunction · 0.85

Tested by

no test coverage detected