Skip to content

onStartTyping

Category
Export Size
757 B
Last Changed
3 hours ago

用户在不可编辑的元素上开始输入时触发。

Demo

输入任何内容

用法

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,
    }
  },
}

Type Declarations

typescript
/**
 * 用户在不可编辑的元素上开始输入时触发回调。
 *
 * @see https://vueuse.org/onStartTyping
 * @param callback
 * @param options
 */
export declare function onStartTyping(
  callback: (event: KeyboardEvent) => void,
  options?: ConfigurableDocument,
): void

Source

SourceDemoDocs

Contributors

jorshen

Changelog

No recent changes

Released under the MIT License.