Skip to content

tuliocastro/node-keyboard-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Keyboard Hook

This Module help you to listen for Keyboard Actions natively. It uses a Java Module (JNativeHook) to intercept the keyboard events. That way you don't need node-gyp to rebuild this module.

Install

npm install --save nkb-hook

Examples

Examples: All the examples are available at 'examples' folder.

var hook = require('../nkbhook.js');

var onPressed = function (pressed) {

    console.log(pressed);
    console.log('You pressed the key with code ' + pressed.code);

};

hook.start().onPressed(onPressed);

Response

The response is a JSON format with the following fields:

{
    action: ..., //Action of event - PRESSED, RELEASED, TYPED
    code: ..., //Key Code
    key: ..., //Key Char
    name: ..., //Key Name
    shift: ..., //If Shift is pressed
    alt: ..., //If alt is pressed
    ctrl: ..., //If ctrl is pressed
    meta: ... //If meta is pressed
}

Table of Key Codes

Esc 1 0x1
1 or ! 2 0x2
2 or @ 3 0x3
3 or # 4 0x4
4 or $ 5 0x5
5 or % 6 0x6
6 or ^ 7 0x7
7 or & 8 0x8
8 or * 9 0x9
9 or ( 10 0xa
0 or ) 11 0xb
- or _ 12 0xc
= or + 13 0xd
Bksp 14 0xe
Tab 15 0xf
Q 16 0x10
W 17 0x11
E 18 0x12
R 19 0x13
T 20 0x14
Y 21 0x15
U 22 0x16
I 23 0x17
O 24 0x18
P 25 0x19
[ or { 26 0x1a
] or } 27 0x1b
Enter 28 0x1c
Left Ctrl 29 0x1d
A 30 0x1e
S 31 0x1f
D 32 0x20
F 33 0x21
G 34 0x22
H 35 0x23
J 36 0x24
K 37 0x25
L 38 0x26
; or : 39 0x27
' or " 40 0x28
` or ~ 41 0x29
Left Shift 42 0x2a
\ or | 43 0x2b
Z 44 0x2c
X 45 0x2d
C 46 0x2e
V 47 0x2f
B 48 0x30
N 49 0x31
M 50 0x32
, or < 51 0x33
. or > 52 0x34
/ or ? 53 0x35
Right Shift 54 0x36
Prtsc
This is a special case
55 0x37
Left Alt 56 0x38
Space 57 0x39
Caps Lock 58 0x3a
F1 59 0x3b
F2 60 0x3c
F3 61 0x3d
F4 62 0x3e
F5 63 0x3f
F6 64 0x40
F7 65 0x41
F8 66 0x42
F9 67 0x43
F10 68 0x44
Num Lock 69 0x45
Scroll Lock 70 0x46
Home (Number Pad) 71 0x47
Up Arrow (Number Pad) 72 0x48
Pgup (Number Pad) 73 0x49
Grey - (Number Pad) 74 0x4a
Left Arrow (Number Pad) 75 0x4b
Center (The 5 key on the number pad?) 76 0x4c
Right Arrow (Number Pad) 77 0x4d
Grey + (Number Pad) 78 0x4e
End (Number Pad) 79 0x4f
Down Arrow (Number Pad) 80 0x50
Pgdn (Number Pad) 81 0x51
Ins (Number Pad) 82 0x52
Del (Number Pad) 83 0x53
Enter (Number Pad) 57372 0xe01c
Right Ctrl 57373 0xe01d
Grey / (Number Pad) 57397 0xe035
Right Alt 57400 0xe038
Home 57415 0xe047
Up Arrow 57416 0xe048
Pgup 57417 0xe049
Left Arrow 57419 0xe04b
Right Arrow 57421 0xe04d
End 57423 0xe04f
Down Arrow 57424 0xe050
Pgdn 57425 0xe051
Ins 57426 0xe052
Del 57427 0xe053
F11 57431 0xe057
F12 57432 0xe058
Left Winkey 57435 0xe05b
Right Winkey 57436 0xe05c

About

NodeJS - Native Keyboard Hook with Java Wrapper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published