Skip to content

Commit

Permalink
feat(www): update keyboard handling for command menu (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn authored Jan 2, 2024
1 parent 6b523b6 commit 98859e7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/www/components/command-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ export function CommandMenu({ ...props }: DialogProps) {

React.useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
if ((e.key === "k" && (e.metaKey || e.ctrlKey)) || e.key === "/") {
if (
(e.target instanceof HTMLElement && e.target.isContentEditable) ||
e.target instanceof HTMLInputElement ||
e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLSelectElement
) {
return
}

e.preventDefault()
setOpen((open) => !open)
}
Expand Down

1 comment on commit 98859e7

@vercel
Copy link

@vercel vercel bot commented on 98859e7 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./apps/www

example-playground.vercel.app
ui.shadcn.com
ui-shadcn-pro.vercel.app
ui-git-main-shadcn-pro.vercel.app

Please sign in to comment.