https://github.com/dennyferra/TypeWatch
A jquery plugin to determine when a user has stopped typing in a text field.
https://github.com/dennyferra/TypeWatch
Last synced: 22 days ago
JSON representation
A jquery plugin to determine when a user has stopped typing in a text field.
- Host: GitHub
- URL: https://github.com/dennyferra/TypeWatch
- Owner: dennyferra
- License: other
- Created: 2012-01-12T19:07:01.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2022-05-01T18:39:38.000Z (over 3 years ago)
- Last Synced: 2025-10-10T12:29:03.333Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 219
- Watchers: 11
- Forks: 54
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome-frontend - TypeWatch - 停止输入时调用
- awesome-frontend - TypeWatch - 停止输入时调用
- awesome-front-end - TypeWatch - 停止输入时调用
README
# The official home for the TypeWatch jQuery plugin. #
[](https://cdnjs.com/libraries/TypeWatch)
TypeWatch calls a function when a user has typed text in an input, textarea and changes in div from editors (including HTML 5 input types) and after the user has stopped typing for a specified amount of time.
> Note* This is not the OnChange event, instead the function is called after the user has finished typing (or if the user stopped typing for # amount of milliseconds) even if the input continues to have focus.
This can be used in conjunction with an AutoComplete implementation, so instead of firing an AJAX call every 500 ms, you can fire it once when they’ve stopped typing.
> Now supports HTML 5 oninput event for browsers that support it
Example:
```javascript
// callback: The callback function
// wait: The number of milliseconds to wait after the the last key press before firing the callback
// highlight: Highlights the element when it receives focus
// allowSubmit: Allows a non-multiline element to be submitted (enter key) regardless of captureLength
// captureLength: Minimum # of characters necessary to fire the callback
var options = {
callback: function (value) { console.log('TypeWatch callback: (' + (this.type || this.nodeName) + ') ' + value); },
wait: 750,
highlight: true,
allowSubmit: false,
captureLength: 2
}
$("#search").typeWatch( options );
```
+ When working with any element other than __TEXTAREA__ pressing the __ENTER__ key will fire the callback function.
+ When working with any editor which supports __DIV__ it works like a textarea.
+ The cut and paste events are also included.
Works with multiple elements:
```javascript
$(".textbox,input,textarea,#search").typeWatch( options );
```
Lastly, if you use or enjoy TypeWatch beer donations are always appreciated
[Donate a beer, half a beer, or a 6-pack](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=95YL35K45G4VA&lc=US&item_name=Denny+Ferrassoli¤cy_code=USD&bn=PP-DonationsBF%3Abtn_donate_SM.gif%3ANonHosted)