Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 1.36 KB

+page.md

File metadata and controls

70 lines (50 loc) · 1.36 KB
title description
Start Typing
Create a typing listener for the given element.
<script> import Meta from "$components/meta.svelte" </script>

Create a typing listener for the given element.

Usage

<script>
    import {startTyping} from "@sveu/actions"

    function fn(element, event){
         if(element !== document.activeElement) element.focus()
    }
</script>

<input use:startTyping="{fn}" />

Example

<script>
    import {startTyping} from "@sveu/actions" // [svp! hl]

    function fn(element, event){
         if(element !== document.activeElement) element.focus() // [svp! hl]
    }
</script>

<input placeholder="Search....." use:startTyping="{fn}" />  <!-- // [svp! hl]  -->

<input placeholder="Enter your name"  />

API

Arguments

Name Description Type Required
fn A function to be called when the user types a character. (element: T, event: KeyboardEvent) => void Yes


:::tip If you use typescript, you need to add ./node_modules/@sveu/actions/events.d.ts to your tsconfig.json file.

{
    ...

    "include": [
        ...
        "./node_modules/@sveu/actions/events.d.ts"
    ]
    ...
}

:::