/MMM-KeyInput

Primary LanguageJavaScriptMIT LicenseMIT

MMM-KeyInput

This is a lightweight module for MagicMirror² to send key-inputs as notifications to active modules, or execute configurable actions.

Installation

Install

In your terminal, go to your MagicMirror² Module folder and clone MMM-KeyInput:

cd ~/MagicMirror/modules
git clone https://github.com/SeeSharpSoft/MMM-KeyInput.git

Update

cd ~/MagicMirror/modules/MMM-KeyInput
git pull

Using the module

Config

To use this module, add it to the modules array in the config/config.js file:

    {
        module: "MMM-KeyInput",
        config: {
          active: true,
          keyBindings: {
            "ArrowLeft": "NOTIFICATION",
            "ArrowRight": ["NOTIFICATION", { payload: true }],
            "Enter": (module, keyEvent) => module.sendNotification("SOME_CUSTOM_EVENT", keyEvent);
          }
        }
    }

Note: Do not add a position to this module.

Configuration options

Option Possible values Default Description
active boolean false Whether the overlay is active/visible
keyBindings object {} Custom actions to be performed on certain keypress

Sending notifications to the module

By default, the overlay is not active/visible. Its visibility can be controlled by sending notifications.

Notification Description
OVERLAY.SHOW Shows (activates) the overlay
OVERLAY.HIDE Hides (deactivates) the overlay
OVERLAY.ACTIVE Payload must contain true/false

Developer commands

  • npm install - Install devDependencies like ESLint.
  • npm run lint - Run linting and formatter checks.
  • npm run lint:fix - Fix linting and formatter issues.