跳到内容

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.org.cn/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 于 3/5/2025
58a3b - 修复:接受了不正确的有效字符 (#4616)
v10.7.0 于 12/5/2023
fccf2 - 特性:升级依赖 (#3614)
v10.0.0-beta.3 于 4/12/2023
e9ab3 - 修复:修复字符 ASCII (#2932)

在 MIT 许可证下发布。