Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snosme/uiohook-napi
https://github.com/snosme/uiohook-napi
cross-platform global-hooks keyboard-events mouse-events n-api nodejs
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/snosme/uiohook-napi
- Owner: SnosMe
- License: mit
- Created: 2020-04-18T21:38:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T04:03:04.000Z (5 months ago)
- Last Synced: 2024-09-19T00:28:22.434Z (about 2 months ago)
- Topics: cross-platform, global-hooks, keyboard-events, mouse-events, n-api, nodejs
- Language: C
- Size: 58.6 KB
- Stars: 170
- Watchers: 9
- Forks: 39
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uiohook-napi
[![](https://img.shields.io/npm/v/uiohook-napi/latest?color=CC3534&label=uiohook-napi&logo=npm&labelColor=212121)](https://www.npmjs.com/package/uiohook-napi)
N-API C-bindings for [libuiohook](https://github.com/kwhat/libuiohook).
### Usage example
```typescript
import { uIOhook, UiohookKey } from 'uiohook-napi'uIOhook.on('keydown', (e) => {
if (e.keycode === UiohookKey.Q) {
console.log('Hello!')
}if (e.keycode === UiohookKey.Escape) {
process.exit(0)
}
})uIOhook.start()
```### API
```typescript
interface UiohookNapi {
on(event: 'input', listener: (e: UiohookKeyboardEvent | UiohookMouseEvent | UiohookWheelEvent) => void): thison(event: 'keydown', listener: (e: UiohookKeyboardEvent) => void): this
on(event: 'keyup', listener: (e: UiohookKeyboardEvent) => void): thison(event: 'mousedown', listener: (e: UiohookMouseEvent) => void): this
on(event: 'mouseup', listener: (e: UiohookMouseEvent) => void): this
on(event: 'mousemove', listener: (e: UiohookMouseEvent) => void): this
on(event: 'click', listener: (e: UiohookMouseEvent) => void): thison(event: 'wheel', listener: (e: UiohookWheelEvent) => void): this
keyTap(key: keycode, modifiers?: keycode[])
keyToggle(key: keycode, toggle: 'down' | 'up')
}export interface UiohookKeyboardEvent {
altKey: boolean
ctrlKey: boolean
metaKey: boolean
shiftKey: boolean
keycode: number
}export interface UiohookMouseEvent {
altKey: boolean
ctrlKey: boolean
metaKey: boolean
shiftKey: boolean
x: number
y: number
button: unknown
clicks: number
}export interface UiohookWheelEvent {
altKey: boolean
ctrlKey: boolean
metaKey: boolean
shiftKey: boolean
x: number
y: number
clicks: number
amount: number
direction: WheelDirection
rotation: number
}
```