keyboard
7 min
the keyboard object allows you to configure the input for a usb keyboard connected to the player keyboard idl interface keypress { attribute string type; attribute number keycode; attribute string key; }; callback keyboardeventcallback = void (keypress event); interface keyboard { promise\<bool> isattached(); promise\<void> setlayout(string layoutname); promise\<void> setnumlock(bool on off); void addeventlistener(string type, keyboardeventcallback callback); void removeeventlistener(string type, keyboardeventcallback callback); }; object creation to create a keyboard object, first load the brightsign/keyboard module using the require() method then create an instance of the keyboard class var keyboardclass = require("@brightsign/keyboard"); var keyboard = new keyboardclass(); keypress this interface contains the following parameters type \<font color="#704ae0">string\</font> type is always “keypress” keycode \<font color="#704ae0">number\</font> the ascii keycode as number key \<font color="#704ae0">string\</font> the ascii character for the keyboard event keyboard this interface allows for detection and configuration of a usb keyboard isattached() promise\<bool> isattached() returns true if a usb keyboard is connected to the player this method counts a connected device as a keyboard if it reports having the following keys "a", "z", "0", "9", " ", and enter setlayout() promise\<void> setlayout(string layoutname) specifies the localized layout for the attached usb keyboard this setting takes effect immediately and persists in the registry after a reboot see this table docid\ vnjf6gns75 lmizet3b1y for valid keymap parameters (players are set to "us" by default) setnumlock() promise\<void> setnumlock(bool on off) sets the numlock state for the attached usb keyboard if passed true reset the state if passed false example var keyboardclass = require("@brightsign/keyboard"); var keyboard = new keyboardclass(); keyboard isattached() then( function(data) { console log(" is attached "); console log(json stringify(data)); }) catch( function(data) { console log(json stringify(data)); }); keyboard setlayout("gb") then( function(data) { console log(" layout set "); }) catch( function(data) { console log(json stringify(data)); });