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

0.18.6 • Public • Published

Bndr

🖱️ ⌇ ⌨️ ⌇ 🎹 ⌇ 🎮 ⌇ 🖊️ ⌇ 👆

DocSandboxAPIBecome a Sponsor

npm version npm licence

Bndr /ˈbaɪndɚ/ is a library designed to compose events from various user inputs and chain filters in a monadic manner, integrating them into a single event object. It accommodates input devices such as mice🖱️, styluses🖊️, touch inputs👆, keyboards⌨️, MIDI controllers🎹, and gamepads🎮. Developed and maintained by Baku Hashimoto.

Potential use cases for this library include:

  • ⚡️ Associating user inputs with arbitrary triggers for VJing
  • 🎨 Introducing manual operations in generative art.

To get a feel for how it works, please try out this demo.

Supported Parameters

  • 👆 Pointer (mouse, stylus, touch)
    • All parameters supported in PointerEvent. (pressure, tilt, multi-touch)
  • ⌨️ Keyboard
  • 🎹 MIDI
    • CC and velocity
  • 🎮 Gamepad
    • Vendor-specific button name support: JoyCon, PS5 Controller

How to use

Installation

npm install bndr-js

Example

import {Bndr} from 'bndr-js'

Bndr.pointer().on(pressed =>
	console.log('Pointer %s', pressed ? 'pressed' : 'released')
)

Bndr.pointer()
	.position()
	.lerp(vec2.lerp, 0.1)
	.on(([x, y]) => console.log('Pointer moved: [%f, %f]', x, y))

Bndr.keyboard()
	.hotkey('shift+c')
	.on(() => console.log('Hotkey shift+c pressed'))

Bndr.keyboard()
	.key('a')
	.on(pressed => console.log(`Key 'a' ${pressed ? 'pressed' : 'released'}`))

Bndr.midi()
	.note(0, 50)
	.on(velocity => console.log('MIDI slider #50 moved: %d', velocity))

Bndr.gamepad()
	.axis(0)
	.on(([x, y]) => console.log('Gamepad axis #0 tilted: [%f, %f]', x, y))

License

This repository is published under an MIT License. See the included LICENSE file.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.18.614latest

Version History

VersionDownloads (Last 7 Days)Published
0.18.614
0.18.50
0.18.40
0.18.30
0.18.20
0.18.10
0.18.00
0.17.01
0.16.01
0.15.11
0.15.01
0.14.20
0.14.11
0.14.00
0.13.20
0.13.11
0.13.00
0.12.00
0.11.20
0.11.10
0.11.01
0.10.01
0.9.40
0.9.30
0.9.20
0.9.11
0.9.00
0.8.00
0.7.10
0.7.01
0.6.01
0.5.11
0.5.00
0.4.00
0.3.20
0.3.10
0.3.01
0.2.00
0.1.00
0.0.10
0.0.00

Package Sidebar

Install

npm i bndr-js

Weekly Downloads

27

Version

0.18.6

License

MIT

Unpacked Size

173 kB

Total Files

36

Last publish

Collaborators

  • baku89