HDMI CEC library that exposes cec-client as an Typescript API.
npm install hdmi-ceccec-client -h gives you an error), you can install it using (with a working internet connection):
bash
sudo apt-get update
sudo apt-get install cec-utils
`
Example
$3
Typescript:
`typescript
import { Remote } from 'hdmi-cec';
// Create a new Remote helper (called without any arguments, it will create a cec-client process itself, with the default client name)
var remote = new Remote();
// When any button is pressed on the remote, we receive the event:
remote.on('keypress', evt => {
console.log(user pressed the key "${evt.key}" with code "${evt.keyCode}");
});
// Alternatively, we only wait for the user to press the "select" key
remote.on('keypress.select', () => {
console.log(user pressed the select key!);
});
`
Javascript:
`javascript
var cecRemote = require('hdmi-cec').Remote;
// Create a new Remote helper (called without any arguments, it will create a cec-client process itself, with the default client name)
var remote = new cecRemote();
// When any button is pressed on the remote, we receive the event:
remote.on('keypress', function(evt) {
console.log('user pressed the key "'+ evt.key + '" with code "' + evt.keyCode + '"');
});
// Alternatively, we only wait for the user to press the "select" key
remote.on('keypress.select', function() {
console.log('user pressed the select key!');
});
``