-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Keypad
Pawel Szymczykowski edited this page Nov 20, 2015
·
29 revisions
The Keypad
class constructs an object that represents a single Keypad attached to the board.
Supported Keypads:
- VKEY
- Waveshare AD (Analog)
- MPR121
- MPR121QR2
- Grove QTouch (AT42QT1070)
-
General Options
Property Type Value/Description Default Required controller string AT42QT1070, MPR121, MPR121QR2, QTOUCH, VKEY, ANALOG. The Name of the controller to use ANALOG Yes keys array Mapping of key values By Device No -
VKEY Options (
controller: "VKEY"
)Property Type Value/Description Default Required pin number, string Analog pin Yes -
ANALOG Options (
controller: "ANALOG"
)Property Type Value/Description Default Required pin number, string Analog pin Yes length number Number of keys (required only if keys
is not specified)Yes
Property Name | Description | Read Only |
---|---|---|
which |
Value of key pressed from keys array |
No |
timestamp |
Timestamp at time of key press | No |
new five.Keypad({
pin: "A0",
length: 16
});
new five.Keypad({
controller: "VKEY",
pin: "A0",
});
new five.Keypad({
controller: "MPR121",
keys: ["!", "@", "#", "$", "%", "^", "&", "-", "+", "_", "=", ":"]
});
new five.Keypad({
controller: "MPR121QR2"
});
new five.Keypad({
controller: "QTOUCH", // or "AT42QT1070"
});
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
// MPR121 3x4 Capacitive Touch Pad
var keypad = new five.Keypad({
controller: "MPR121",
keys: [
["!", "@", "#"],
["$", "%", "^"],
["&", "-", "+"],
["_", "=", ":"]
]
});
["change", "press", "hold", "release"].forEach(function(eventType) {
keypad.on(eventType, function(data) {
console.log("Event: %s, Target: %s", eventType, data.which);
});
});
});
-
hold The key has been held for
holdtime
milliseconds -
down, press The key has been pressed.
-
up, release The key has been released.