跳到主要內容

onStartTyping

分類
導出大小
757 B
最後更改
上週

當使用者開始在不可編輯的元素上輸入時觸發。

範例

輸入任何內容

用法

vue
<input ref="input" type="text" placeholder="Start typing to focus" />
ts
import { onStartTyping } from '@vueuse/core'

export default {
  setup() {
    const input = ref(null)

    onStartTyping(() => {
      if (!input.value.active)
        input.value.focus()
    })

    return {
      input,
    }
  },
}

類型宣告

typescript
/**
 * Fires when users start typing on non-editable elements.
 *
 * @see https://vueuse.dev.org.tw/onStartTyping
 * @param callback
 * @param options
 */
export declare function onStartTyping(
  callback: (event: KeyboardEvent) => void,
  options?: ConfigurableDocument,
): void

原始碼

原始碼範例文件

貢獻者

Anthony Fu
Anthony Fu
Bernard Borg
meenie-net
丶远方
Alex Kozack
Nurettin Kaya
Antério Vieira
Seifeldin Mahjoub

更新日誌

v12.8.0 於 2025/3/5
58a3b - 修復:不正確的可接受有效字元 (#4616)
v10.7.0 於 2023/12/5
fccf2 - 功能:升級依賴 (#3614)
v10.0.0-beta.3 於 2023/4/12
e9ab3 - 修復:修復字元 ascii (#2932)

以 MIT 許可證發布。