logitech-craft-plugin
A JavaScript (and TypeScript) API for creating a Logitech Options Craft keyboard plugin.
Make sure to reference the official Craft SDK documentation as well.
API and Example
import { CraftPlugin } from 'logitech-craft-plugin';
const craftKeyboard = new CraftPlugin({
pluginGuid: '93928702-2f0b-4b5d-b125-394b29d9fba5',
reconnect: true
});
craftKeyboard.on('connect:begin', () => {
console.log('Connecting to Craft keyboard');
});
craftKeyboard.on('connect:done', () => {
console.log('Connected to Craft keyboard');
});
craftKeyboard.on('connect:failed', (ex) => {
console.log('Failed to connect to Craft keyboard', ex.message);
});
craftKeyboard.on('crown:turn', () => {
console.log('Crown turned some amount');
});
craftKeyboard.on('crown:turn:positive', () => {
console.log('Crown turned right');
});
craftKeyboard.on('crown:turn:negative', () => {
console.log('\nCrown turned left');
});
craftKeyboard.on('crown:touch', () => {
console.log('Crown touched or released');
});
craftKeyboard.on('crown:touch:touched', () => {
console.log('Crown touched');
});
craftKeyboard.on('crown:touch:released', () => {
console.log('Crown released');
});
craftKeyboard.changeTool(toolIdString);
craftKeyboard.close();
More Extensive Example
This code is used in the Logitech Craft VS Code extension.