Members
-
<readonly> isClosed :boolean
-
Description
True if the button is being pressedDetails
-
<readonly> isOpen :boolean
-
Description
True if the button is not being pressedDetails
-
<readonly> downValue :number
-
Description
Get the raw downValue (depends on type and io input mode)Details
-
<readonly> upValue :number
-
Description
Get the raw upValue (depends on type and io input mode)Details
-
holdtime :number
-
Description
The length of time a button must be held before firing a hold event (in ms)Details
Methods
-
on( event, listener )
-
Description
Create an event listenerParameters
Name Type Description event
string The name of the event to listen for listener
function A callback to run when the event is fired. Details
-
removeListener( event, listener )
-
Description
Remove an event listenerParameters
Name Type Description event
string The name of the event that we are removing a listener from listener
function The callback that we are removing Details
-
once( event, listener )
-
Description
Create an event listener that will only fire one time.Parameters
Name Type Description event
string The name of the event to listen for listener
function A callback to run when the event is fired. Details
-
configure( options ) → {Button}
-
Description
Configure a buttonParameters
Name Type Description options
object Device configuration options Name Type Attributes Default Description holdtime
number <optional> 500 The amount of time a button must be held down before emitting an hold event debounce
number <optional> 7 The amount of time in milliseconds to delay button events firing. Cleans up "noisy" state changes type
string <optional> "NO" The type of button, "NO" for normally open, "NC" for normally closed Returns
Examples
import Button from "j5e/button"; import LED from "j5e/led"; const button = await new Button(14); button.configure({ debounce: 20 }); button.on("open", function() { led.off(); }); button.on("close", function() { led.on(); });
Details