Fork from the original excellent MMM-Keyboard module for the MagicMirror² that creates a virtual keyboard to be used to send commands or text to other modules
cd ~/MagicMirror/modules
git clone https://github.com/jheyman/MMM-Keyboard.git
cd MMM-Keyboard
npm install
Add this configuration into your config.js
file
{
module: "MMM-Keyboard",
position: "fullscreen_above",
config: {
style: "default",
}
}
The keyboard works with MagicMirror's notification system. You can broadcast notifications from another module using the following parameters
this.sendNotification("KEYBOARD", {
key: "uniqueKey",
style: "default"
});
The payload of the notification must be an object containing two parameters:
key
: You can use any unique key, it is advised to use the module name. MMM-Keyboard will take the key and send it back for the module to understand it.
style
: Use "default" or "numbers" here,
As soon as you hit the "SEND!"-Button the keyboard sends back the written content using the format
this.sendNotification("KEYBOARD_INPUT", {
key: "uniqueKey",
message: "test"
});
You can fetch this message by checking for the key
component. Here an example:
notificationReceived : function (notification, payload) {
if (notification == "KEYBOARD_INPUT" && payload.key === "uniqueKey") {
console.log(payload.message);
}
},