1.2.0 • Published 7 years ago

keywatcher v1.2.0

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

keywatcher

JS For watching key inputs

Two functions:

watchKeys(inputEl, keyPress, onDelete)

Params

  • inputEl: the element to listen on
  • keyPress: a callback for any keypressed
  • onDelete: a callback for the backspace or delete key pressed

watchKeyup(inputEl, keyUp)

Params

  • inputEl: the element to listen on
  • keyUp: the callback for a key released

Example

var el = document.getElementById('element')

watchKeys(el, function onKeyPress (e) {
  console.log('Key pressed: '+e.key)
}, function onDelete (e) {
  console.log('Either backspace or delete: '+e.key)
})

watchKeyup(el, function onKeyUp (e) {
  console.log('Key released: '+e.key)
})

Notes

  • watchKeys uses the keyPressed event, which is currently deprecated. See MDN
  • the keyPress callback is not called when the delete or backspace key is pressed
1.2.0

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago