onStartTyping
Fires when users start typing on non-editable elements.
Demo
Type anything
Usage
html
<input ref="input" type="text" placeholder="Start typing to focus" />
<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,
}
},
}
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
/**
* Fires when users start typing on non-editable elements.
*
* @see https://vueuse.org/onStartTyping
* @param callback
* @param options
*/
export declare function onStartTyping(
callback: (event: KeyboardEvent) => void,
options?: ConfigurableDocument
): void
/**
* Fires when users start typing on non-editable elements.
*
* @see https://vueuse.org/onStartTyping
* @param callback
* @param options
*/
export declare function onStartTyping(
callback: (event: KeyboardEvent) => void,
options?: ConfigurableDocument
): void
Source
Contributors
Anthony Fu
Alex Kozack
Nurettin Kaya
Antério Vieira
Seifeldin Mahjoub