In contrast to the somewhat limited possibilities of the xml defined keys, you can also provide a lua script.

The script is defined for a specific key and has control over the key press and the LED state of said key. The key can keep a state during the phones activity and is therefore able to perform more complex tasks than the stateless xml configuration.

The lua-environment contains interfaces to invoke calls, prepare subscriptions, send http requests or register handlers for incoming http. We have documented this API here.


      --[===]simple script used for setting LEDs[===]--
      local state = 0
      --[===]onKeyUp is called when the key is released[===]--
      function onKeyUp()
        state = (state + 1) % 7
        if state == 0  then
            --[===]set the configured key LED to off[===]--
            key:setLed( "off" )
        elseif state == 1 then
            key:setLed( "red" )
        elseif state == 2 then
            key:setLed( "red", true )
        elseif state == 3 then
            key:setLed( "orange" )
        elseif state == 4 then
            key:setLed( "orange", true )
        elseif state == 5 then
            key:setLed( "green" )
            key:setLed( "green", true )