Skip to main content

Overview

React Grab supports two activation modes that control how you enter and exit inspection mode:
  • Toggle mode (default) - Press once to activate, press again to deactivate
  • Hold mode - Hold the key to activate, release to deactivate

Activation Modes

Toggle Mode

In toggle mode, a single keypress activates React Grab and it stays active until you press the key again.
Behavior:
  1. Press ⌘C (Mac) or Ctrl+C (Windows/Linux) to activate
  2. Inspection mode stays active until you:
    • Press the activation key again to deactivate
    • Successfully copy an element (optional auto-deactivate)
    • Press Escape
Use Cases:
  • Extended inspection sessions
  • Comparing multiple elements
  • Copying several elements in sequence
  • Keyboard-driven navigation with arrow keys

Hold Mode

In hold mode, React Grab activates only while you hold down the activation key.
Behavior:
  1. Press and hold the activation key for keyHoldDuration milliseconds
  2. Inspection mode activates while key is held
  3. Release the key to immediately deactivate
Implementation:
The system enters “holding” state on keydown, then transitions to “active” after the hold duration expires. On keyup, it immediately deactivates. Use Cases:
  • Quick one-off inspections
  • Preventing accidental activation
  • Muscle memory from DevTools (inspect-on-hover)
  • Minimal interference with normal keyboard shortcuts

Keyboard Shortcuts

Default Activation Key

By default, React Grab uses the native copy shortcut:
  • Mac: ⌘C (Command+C)
  • Windows/Linux: Ctrl+C
The implementation detects the platform:

Copy Protection

When activated via the copy shortcut, React Grab prevents the default browser copy action:

Context-Aware Activation

React Grab intelligently handles activation inside inputs:
Constants used:

Additional Shortcuts

When React Grab is active:

Activation Key Customization

You can customize the activation key using the activationKey option:

String Format

Custom Function

For complex key combinations:

Examples

Single key:
With modifiers:
Function key:

Parsing Activation Keys

Internally, React Grab parses activation keys:

Hold Duration Configuration

The keyHoldDuration option controls how long you must hold the key before activation:
Recommended values:
  • 100ms (default) - Quick activation, minimal delay
  • 200ms - More deliberate, prevents accidental activation
  • 50ms - Very responsive, may activate unintentionally

Implementation Details

The hold timer prevents activation from brief keypresses (like double-tapping copy):

State Transitions

The activation state machine:
Toggle mode transitions:
Hold mode transitions:

Toolbar Control

The floating toolbar provides a visual toggle:
Clicking the toolbar toggle activates in toggle mode regardless of the configured activationMode:

Best Practices

Toggle mode is ideal when:
  • You’re inspecting multiple elements in sequence
  • You want to use arrow keys to navigate the component tree
  • You’re comparing elements across different parts of the UI
  • You want inspection mode to persist while you scroll or switch windows
Example: Debugging a complex layout with nested components
Hold mode is ideal when:
  • You want minimal interference with keyboard shortcuts
  • You prefer inspect-on-demand behavior
  • You’re making quick one-off inspections
  • You want to prevent accidental activation
Example: Quickly checking a single component’s source location
Combine activation mode with other options for optimal workflow:

Configuration Examples

Default Configuration

Hold Mode with Custom Key

Toggle Mode with Function Key

Custom Modifier Combination