0.1.3 • Published 7 years ago

delay-keyup v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Delay Keyup

Sets an event handler when a keyup event fires after a specified timeout.

Install

npm install delay-keyup

Example

<input type="text" name="test"/>

<script src="jquery.js"></script>
<script src="delay-keyup.js"></script>
<sciprt>
    //There are several ways to use this plugin:
    //First, HTMLElement
    document.querySelector("input").delayKeyup(function(){
        this.value = this.value.toUpperCase();
    });

    //Second, NodeList
    document.querySelectorAll("input").delayKeyup(function(){
        this.value = this.value.toUpperCase();
    });

    //Third, jQuery
    $("input").daleyKeyup(function(){
        $(this).val( $(this).val().toUpperCase() );
    });

    //Or, just call the function
    delayKeyup("input", function(){
        this.value = this.value.toUpperCase();
    });
</sciprt>

Import in WebPack

import delayKeyup from "delay-keyup";
//Or
import "delay-keyup"; //Recommanded

Or in AMD

define(["delay-timeout"], function(){
    //Do stuffs here...
});

Sets a specified timeout

Default, the event handler will be triggered after 1500 milliseconds, but you can pass the second or third argument to this function a number to specified a custom timeout.

import "delay-keyup";

//The second argument
document.querySelector("input").delayKeyup(function(){
    this.value = this.value.toUpperCase();
}, 3000);

//The third argument
delayKeyup("input", function(){
    this.value = this.value.toUpperCase();
}, 3000);
0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago