跳到主要内容

onStartTyping

分类
导出大小
825 B
上次更改
8 个月前

当用户开始在不可编辑元素上打字时触发。

演示

用法

vue
<script setup lang="ts">
import { 
onStartTyping
} from '@vueuse/core'
import {
useTemplateRef
} from 'vue'
const
input
=
useTemplateRef
('input')
onStartTyping
(() => {
if (!
input
.
value
.active)
input
.
value
.
focus
()
}) </script> <template> <
input
ref
="
input
"
type
="text"
placeholder
="Start typing to focus">
</template>

类型声明

ts
/**
 * 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
SerKo
Bernard Borg
meenie-net
丶远方
Alex Kozack
Nurettin Kaya
Antério Vieira
Seifeldin Mahjoub

更新日志

v12.8.0
58a3b - 修复:接受的有效字符不正确 (#4616)
v10.7.0
fccf2 - feat: 升级依赖 (#3614)

根据 MIT 许可证发布。