The following remote control keys are mandatory input device keys. They are available to an application on any Tizen TV.
The Tizen TV may provide additional keys depending on a particular input device. An application can handle device dependent key events after registration.
Since: 2.4
Interface | Method |
---|---|
TVInputDeviceManagerObject | |
InputDeviceKey | |
TVInputDeviceManager |
void registerKey (InputDeviceKeyName keyName)
void unregisterKey (InputDeviceKeyName keyName)
void registerKeyBatch (InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
void unregisterKeyBatch (InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) |
[NoInterfaceObject] interface TVInputDeviceManagerObject {
readonly attribute TVInputDeviceManager tvinputdevice;
};
Tizen implements TVInputDeviceManagerObject;
Since: 2.4
There is a tizen.tvinputdevice object that allows accessing the functionality of the TV Input Device API.
[NoInterfaceObject] interface InputDeviceKey {
readonly attribute InputDeviceKeyName name;
readonly attribute long code;
};
Since: 2.4
If the key is listed in the DOM Level 3 KeyboardEvent key Values specification, the name attribute is equal to the key value specified there. (The Media Controller Keys section is the most relevant to the Input Device API)
If the "DOM Level 3 KeyboardEvent key Value" does not contain appropriate entry for the key, then the Input Device provides a device specific name.
Since: 2.4
This is the keyCode attribute value of the Key Event generated by the key.
Since: 2.4
[NoInterfaceObject] interface TVInputDeviceManager {
InputDeviceKey[] getSupportedKeys() raises(WebAPIException);
InputDeviceKey? getKey(InputDeviceKeyName keyName) raises(WebAPIException);
void registerKey(InputDeviceKeyName keyName) raises(WebAPIException);
void unregisterKey(InputDeviceKeyName keyName) raises(WebAPIException);
void registerKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
void unregisterKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
};
Since: 2.4
getSupportedKeys
InputDeviceKey[] getSupportedKeys();
Since: 2.4
Mandatory keys will not be retrieved by this method.
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in case of any error.
Code example:
var i, keyCode = {}, supportedKeys;
supportedKeys = tizen.tvinputdevice.getSupportedKeys();
for (i = 0; i < supportedKeys.length; i++) {
keyCode[supportedKeys[i].name] = supportedKeys[i].code;
}
if(keyCode.hasOwnProperty("ChannelUp")) {
tizen.tvinputdevice.registerKey("ChannelUp");
}
window.addEventListener("keydown", function(keyEvent) {
// identify the key by the numeric code from the keyEvent
if(keyEvent.keyCode === keyCode.ChannelUp) {
console.log("The CHANNEL UP was pressed");
}
});
getKey
InputDeviceKey? getKey(InputDeviceKeyName keyName);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Parameters:
Return value:
InputDeviceKey InputDeviceKey object for the given key name, or null if the key is not supportedExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidValuesError if the given keyName is invalid (e.g. name is empty string)
with error type UnknownError in any other error case.
registerKey
void registerKey(InputDeviceKeyName keyName);
Since: 2.4
When an application wants to react to the Input Device keys being pressed, it should register this key.
An application cannot register the mandatory keys (ArrowLeft, ArrowRight, ArrowUp, ArrowDown, Enter, Back).
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidValuesError, if the given keyName is invalid or not supported (e.g. name is empty string).
with error type UnknownError in any other error case.
Code example:
var keys = ["VolumeUp", "VolumeDown"], i;
for (i = 0; i < keys.length; i++) {
try {
tizen.tvinputdevice.registerKey(keys[i]);
} catch(error) {
console.log("failed to register " + keys[i] + ": " + error);
}
}
unregisterKey
void unregisterKey(InputDeviceKeyName keyName);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidValuesError, if the given keyName is invalid or not supported (e.g. name is empty string).
with error type UnknownError in any error case.
Code example:
tizen.tvinputdevice.unregisterKey("VolumeDown");
registerKeyBatch
void registerKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
When an application wants to react to the input device key presses, it should register those keys.
An application cannot register the mandatory keys (ArrowLeft, ArrowRight, ArrowUp, ArrowDown, Enter, Back).
The errorCallback is launched with this error type:
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidValuesError, if any of the given keyNames is invalid or not supported (e.g. name is empty string).
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError in any other error case.
Code example:
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function successCB() {
console.log('Registered successfully');
}
var keys = ["VolumeUp", "VolumeDown"];
tizen.tvinputdevice.registerKeyBatch(keys, successCB, errorCB);
unregisterKeyBatch
void unregisterKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
The errorCallback is launched with this error type:
Privilege level: public
Privilege: http://tizen.org/privilege/tv.inputdevice
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidValuesError, if any of the given keyNames is invalid or not supported (e.g. name is empty string).
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError in any error case.
Code example:
function errorCB(err) {
console.log( 'The following error occurred: ' + err.name);
}
function successCB() {
console.log('Unregistered successfully');
}
var keys = ["VolumeUp", "VolumeDown"];
tizen.tvinputdevice.unregisterKeyBatch(keys, successCB, errorCB);
To guarantee the running of this application on a device with a TV input device support, define the following requirements in the config file:
For more information, see Application Filtering.
module TVInputDevice {
typedef DOMString InputDeviceKeyName;
[NoInterfaceObject] interface TVInputDeviceManagerObject {
readonly attribute TVInputDeviceManager tvinputdevice;
};
Tizen implements TVInputDeviceManagerObject;
[NoInterfaceObject] interface InputDeviceKey {
readonly attribute InputDeviceKeyName name;
readonly attribute long code;
};
[NoInterfaceObject] interface TVInputDeviceManager {
InputDeviceKey[] getSupportedKeys() raises(WebAPIException);
InputDeviceKey? getKey(InputDeviceKeyName keyName) raises(WebAPIException);
void registerKey(InputDeviceKeyName keyName) raises(WebAPIException);
void unregisterKey(InputDeviceKeyName keyName) raises(WebAPIException);
void registerKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
void unregisterKeyBatch(InputDeviceKeyName[] keyNames, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
};
};