mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 13:49:09 +03:00
feat: set modifiersKey to be alt, meta, crtl and tab
This commit is contained in:
1 parent
f9917c6aa8
commit
02fd34ec32
1 file changed
+6
-4
@@ -408,8 +408,10 @@ export function useAutoInputFocus() {
|
||||
|
||||
// Focus the input when typing from anywhere
|
||||
React.useEffect(() => {
|
||||
function isModifierNotShift(event: KeyboardEvent) {
|
||||
return event.key.length !== 1 && event.key !== 'Shift'
|
||||
function isModifierKey(event: KeyboardEvent) {
|
||||
const modifierKeys = ['Alt', 'Control', 'Meta', 'Tab']
|
||||
const { key } = event
|
||||
return modifierKeys.includes(key)
|
||||
}
|
||||
|
||||
// Keep track of whether the modifier key (except shift) is pressed
|
||||
@@ -417,7 +419,7 @@ export function useAutoInputFocus() {
|
||||
|
||||
function onKeyDown(event: KeyboardEvent) {
|
||||
// If the user is typing a modifier key, don't focus the input and set the modifierPressed flag
|
||||
if (isModifierNotShift(event)) {
|
||||
if (isModifierKey(event)) {
|
||||
modifierPressed = true
|
||||
} else {
|
||||
if (!modifierPressed) {
|
||||
@@ -428,7 +430,7 @@ export function useAutoInputFocus() {
|
||||
}
|
||||
function onKeyUp(event: KeyboardEvent) {
|
||||
console.log('keyup')
|
||||
if (isModifierNotShift(event)) {
|
||||
if (isModifierKey(event)) {
|
||||
// Reset the modifierPressed flag when the modifier key is released
|
||||
modifierPressed = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user