Key

CONSTANTS


key.start()

Description

initialize a GPIO pin as an input “key”.

Syntax

key.start(pin, callback_short_press, callback_long_press, long_press_threshold)

Parameters

pin: 0~15, GPIO index
callback_short_press: function to execute on short press
callback_long_press(option): function to execute on long press
long_press_threshold(option): the value in million-seconds to distinguish between short and long press

Returns

nil

Example

key.start(0, function()
print("short")
end,
function()
print("long")
end, 2000) –milliseconds

See also