Modal add Esc shortcut
This commit is contained in:
parent
3db21e7e95
commit
38010a9556
@ -1,6 +1,6 @@
|
|||||||
import { XIcon } from '@heroicons/react/outline'
|
import { XIcon } from '@heroicons/react/outline'
|
||||||
import React, { ReactNode, useRef } from 'react'
|
import React, { ReactNode, useRef } from 'react'
|
||||||
import { useClickAway } from 'react-use'
|
import { useClickAway, useKey } from 'react-use'
|
||||||
import Button from './Button'
|
import Button from './Button'
|
||||||
|
|
||||||
interface ModalProps {
|
interface ModalProps {
|
||||||
@ -17,6 +17,10 @@ export default function Modal(props: ModalProps) {
|
|||||||
onClose?.()
|
onClose?.()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
useKey('Escape', onClose, {
|
||||||
|
event: 'keydown',
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={[
|
className={[
|
||||||
|
@ -31,8 +31,8 @@ export default function ShortcutsModal(props: ShortcutsModalProps) {
|
|||||||
<ShortCut content="Enable multi-stroke mask drawing">
|
<ShortCut content="Enable multi-stroke mask drawing">
|
||||||
<p>Hold Cmd/Ctrl</p>
|
<p>Hold Cmd/Ctrl</p>
|
||||||
</ShortCut>
|
</ShortCut>
|
||||||
<ShortCut content="Enable panning">
|
<ShortCut content="Pan">
|
||||||
<p>Hold Space</p>
|
<p>Space & Drag</p>
|
||||||
</ShortCut>
|
</ShortCut>
|
||||||
<ShortCut content="View original image">
|
<ShortCut content="View original image">
|
||||||
<p>Hold Tab</p>
|
<p>Hold Tab</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user