import type { KeyboardEvent } from 'react'

export function useDialogSubmitShortcut(submit: () => void) {
  return (e: KeyboardEvent) => {
    if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
      e.preventDefault()
      submit()
    }
  }
}
