Key Service

The Key service - com.palm.keys - provides information about keypresses and other device events. Status methods are provided for different types of key events.


Methods


audio/status

Returns status events for the device's volume keys (up or down).

Syntax

{
    "subscribe" : boolean
}

Parameters

Parameter Type Required Description
subscribe boolean No Set to true to receive keypress events. Default is false.

Returns

{
    "returnValue" : boolean,
    "subscribed"  : boolean,
    "key"         : string,
    "state"       : string
}
Attribute Required Type Description
returnValue No boolean true (success) or false (failure). Returned in initial result.
key No string Key - volume_up|volume_down.
state No string Key state - up|down.
subscribed No boolean Did subscription succeed? Returned in initial result.

Examples

luna-send

luna-send -n -i palm://com.palm.keys/audio/status '{"subscribe":true}'
{ "returnValue": true, "subscribed": true }
{ "key": "volume_up", "state": "down" }
{ "key": "volume_up", "state": "up" }
. . .

Mojo

this.controller.serviceRequest('palm://com.palm.keys/audio', {
    method:'status',
    parameters:{"subscribe":true},
    onSuccess : function (r){ Mojo.Log.info("Success, results="+JSON.stringify(r)); },
    onFailure : function (r){ Mojo.Log.info("Failure, results="+JSON.stringify(r)); }   
});

media/status

Returns status events for the following keys:

Parameters

Parameter Type Required Description
subscribe boolean No Set to true to receive keypress events. Default is false.

Returns

{
    "returnValue" : boolean,
    "key"         : string,
    "state"       : string,
    "subscribed"  : boolean
}
Attribute Type Requred Description
returnValue boolean No true (success) or false (failure). Returned in initial result.
key string No The key - play|pause|stop|next|prev.
state string No Key state - up|down.
subscribed boolean No Did subscription succeed? Returned in initial result.

Examples

Mojo

this.controller.serviceRequest('palm://com.palm.keys/media', {
    method:'status',
    parameters:{"subscribe":true},
    onSuccess : function (r){ Mojo.Log.info("Success, results="+JSON.stringify(r)); },
    onFailure : function (r){ Mojo.Log.info("Failure, results="+JSON.stringify(r)); }   
});

switches/status

Returns status events for the following keys:

Parameters

Parameter Type Required Description
subscribe boolean No Set to true to receive keypress events. Default is false.

Returns

{
    "returnValue" : boolean,
    "key"         : string,
    "state"       : string,
    "subscribed"  : boolean
}
Attribute Type Requred Description
returnValue boolean No true (success) or false (failure). Returned in initial result.
key string No The key - ringer|slider.
state string No Key state - up|down.
subscribed boolean No Did subscription succeed? Returned in initial result.

Examples

luna-send

luna-send -n -i palm://com.palm.keys/switches/status '{"subscribe":true}'
{ "returnValue": true, "subscribed": true }
{ "key": "ringer", "state": "up" }
{ "key": "ringer", "state": "down" }
. . .

Mojo

this.controller.serviceRequest('palm://com.palm.keys/switches', {
    method:'status',
    parameters:{"subscribe":true},
    onSuccess : function (r){ Mojo.Log.info("Success, results="+JSON.stringify(r)); },
    onFailure : function (r){ Mojo.Log.info("Failure, results="+JSON.stringify(r)); }   
});

headset/status

Returns status events for the following keys:

Parameters

Parameter Type Required Description
subscribe boolean No Set to true to receive keypress events. Default is false.

Returns

{
    "returnValue" : boolean,
    "key"         : string,
    "state"       : string,
    "subscribed"  : boolean
}
Attribute Type Requred Description
returnValue boolean No true (success) or false (failure). Returned in initial result.
key string No The key - headset_button|headset-mic.
state string No Key state.

For headset_button:
  • up
  • down
  • hold
  • single-click
  • double-click

For headset-mic:
  • up
  • down
subscribed boolean No Did subscription succeed? Returned in initial result.

Examples

luna-send

 luna-send -n -i palm://com.palm.keys/headset/status '{"subscribe":true}'
{ "returnValue": true, "subscribed": true }
{ "key": "headset_button", "state": "down" }
{ "key": "headset_button", "state": "single_click" }
{ "key": "headset_button", "state": "up" }
. . .

Mojo

this.controller.serviceRequest('palm://com.palm.keys/headset', {
    method:'status',
    parameters:{"subscribe":true},
    onSuccess : function (r){ Mojo.Log.info("Success, results="+JSON.stringify(r)); },
    onFailure : function (r){ Mojo.Log.info("Failure, results="+JSON.stringify(r)); }   
});