clickdown
TypeScript icon, indicating that this package has built-in type declarations

1.3.4 • Public • Published

clickdown

jsr - npmjs - demo

Speeds up clicks by combining the speed of pointerdown and the features of click in a single "clickdown" event.

It attaches the onclickdown function to Element and HTMLElement prototypes, which means you can use it with getElementById, querySelector, and others.

Install

# With npm on npmjs.com
npm install clickdown

# With Deno on jsr.io
deno add jsr:@victr/clickdown

You can use it in two ways: by importing onclickdown from clickdown/mod, or by augmenting the Element prototype by importing clickdown.

import { onclickdown } from 'clickdown/mod'

const input = document.getElementById('my-input')
const listener = () => console.log('Hello world !')

onclickdown(input, listener, {
  propagate: false,
})
import 'clickdown'

const input = document.getElementById('my-input')
const listener = () => console.log('Hello world !')

input.onclickdown(listener, {
  propagate: false,
})

jsr does not support augmenting the global type. Only named exports are available:

import { onclickdown } from "@victr/clickdown"

onclickdown(document.body, (event) => console.log(event.type))

Package Sidebar

Install

npm i clickdown

Weekly Downloads

25

Version

1.3.4

License

MIT

Unpacked Size

9.69 kB

Total Files

7

Last publish

Collaborators

  • victr