LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. States & patterns

Keyboard shortcut

Also called hotkey or keybinding

A key combination that runs an action directly, like ⌘S to save or ⌘K to open search, so frequent users can skip the mouse.

import { useEffect, useState } from 'react';
import { Dialog } from '@base-ui/react/dialog';

const IS_MAC = /Mac|iPhone|iPad/.test(navigator.userAgent);

export function SearchShortcut() {
  const [open, setOpen] = useState(false);

  useEffect(() => {
    function onKeyDown(event: KeyboardEvent) {
      // ⌘K on a Mac, Ctrl+K everywhere else.
      const mod = IS_MAC ? event.metaKey : event.ctrlKey;
      if (!mod || event.key.toLowerCase() !== 'k') return;
      event.preventDefault(); // only for the combination we handle
      setOpen((current) => !current);
    }
    window.addEventListener('keydown', onKeyDown);
    return () => window.removeEventListener('keydown', onKeyDown);
  }, []);

  return (
    <Dialog.Root open={open} onOpenChange={setOpen}>
      <Dialog.Trigger className='flex w-56 items-center justify-between rounded-lg border px-3 py-1.5 text-sm text-muted-foreground hover:bg-muted'>
        Search
        <kbd className='rounded border bg-muted px-1.5 font-sans text-xs'>
          {IS_MAC ? '⌘' : 'Ctrl'} K
        </kbd>
      </Dialog.Trigger>
      <Dialog.Portal>
        <Dialog.Backdrop className='fixed inset-0 bg-black/30 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0' />
        {/* Esc closes it; Base UI handles that. */}
        <Dialog.Popup className='fixed top-24 left-1/2 w-full max-w-lg -translate-x-1/2 rounded-xl border bg-background p-2 shadow-xl transition-[opacity,scale] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0'>
          <Dialog.Title className='sr-only'>Search</Dialog.Title>
          <input
            placeholder='Search projects and commands'
            className='w-full bg-transparent px-3 py-2 text-sm outline-none'
          />
        </Dialog.Popup>
      </Dialog.Portal>
    </Dialog.Root>
  );
}
Add keyboard shortcuts: ⌘K (Ctrl+K on Windows) opens the command palette, ⌘S saves the document and shows a "Saved" badge, and Esc closes any open dialog. Show ⌘ or Ctrl in menus and tooltips based on the platform, call preventDefault only for these combinations, ignore single-key shortcuts while typing in inputs, and add a "?" panel that lists every shortcut.

Paste into Layerwise or any AI coding tool.

What is Keyboard shortcut?

Keyboard shortcuts let people act without reaching for the mouse: ⌘S (Ctrl+S on Windows) saves, ⌘K opens search or a command palette, ⌘B makes text bold, and Esc closes whatever is open. They make an app faster for the people who use it every day.

Follow the conventions people already know before inventing new ones, and make shortcuts easy to discover: show them next to menu items and in tooltips, and list them all in a help panel, often opened with ?. Show ⌘ on a Mac and Ctrl everywhere else.

When building them, check metaKey on a Mac and ctrlKey elsewhere, call preventDefault() only for the combinations you handle, and ignore single-key shortcuts while focus is in a text field so typing doesn’t trigger them. Avoid combinations the browser or operating system keeps for itself, such as ⌘W and ⌘Q.

Often confused with

Command palette
A command palette is a searchable list of actions, often opened with ⌘K. A keyboard shortcut is any key combination that runs an action directly.

Related terms

All terms

Command palette

A search box that opens with a shortcut like ⌘K and lets you find and run any command or page by typing a few letters.

Focus ring

An outline that marks which element has keyboard focus, so people moving through a page with the Tab key can see where they are.

Tooltip

A small label that appears next to an element when you hover over it or focus it, naming an icon button or adding a short hint.

Interaction states

The set of looks a control takes as people use it, such as default, hover, pressed, focused, and disabled, each showing what will happen.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
Launch notesSaved

We ship the new onboarding on Friday. Share feedback in the design channel before then.

⌘+BBold