mirror of
https://github.com/supabase/supabase.git
synced 2026-06-22 07:22:07 +08:00
23 lines
529 B
TypeScript
23 lines
529 B
TypeScript
import { useState, useEffect } from 'react'
|
|
|
|
const ACTION_KEY_DEFAULT = ['Ctrl ', 'Control']
|
|
const ACTION_KEY_APPLE = ['⌘', 'Command']
|
|
|
|
export function useActionKey() {
|
|
let [actionKey, setActionKey] = useState()
|
|
|
|
useEffect(() => {
|
|
if (typeof navigator !== 'undefined') {
|
|
if (/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
|
|
// @ts-ignore
|
|
setActionKey(ACTION_KEY_APPLE)
|
|
} else {
|
|
// @ts-ignore
|
|
setActionKey(ACTION_KEY_DEFAULT)
|
|
}
|
|
}
|
|
}, [])
|
|
|
|
return actionKey
|
|
}
|