Phone API Reference - UI Classes (Widgets) - Widget (Base Class) - onkey[key]
Phone API Reference - UI Classes (Widgets) - Widget (Base Class) - onkey[key]
onkey[key]
Description
Handler for when the key specified by [key] is pressed. Key handlers start by checking on the current focused widget. If none are found, they will move up the UI chain to any parent widgets.
Basic Example:
window.onkey2 = function() { util.debug('2'); };
window.onkey4 = function() { util.debug('4'); };
window.onkey6 = function() { util.debug('6'); };
window.onkey8 = function() { util.debug('8'); };
window.onkey* = digium.background;
// all other keys would use this
window.onkey = function(evt) {
util.debug('one of my other keys');
util.debug(JSON.parse(evt)); //{"key" : "keyname", "type" : "key" }
} |
onkey{dpad}: {dpad} can be (left, right, down, up, select, cancel), corresponding to the 6 dpad buttons
onkeyline{N}: {N} can be any line 2-6 that your phone currently supports, which is up to 6 on a D70. Note: onkeyline1 is reserved for closing the app (putting it into the background). For example, onkeyline2 = function(){}
onkey{N}: {N} can be 0-9 and corresponds to the number pad. For example, onkey2 = function(){}
onkey* or onkeystar: star / asterisk key on number pad.
onkey# or onkeypound: pound key on number pad.
onkeyv{vol}: {vol} can be either up or down. For example, onkeyvup = function(){}.
onkey{function}: {function} can be any of the various functional keys on your phone. Possibilites are as follows: status, menu, dir, apps, info, conf, hdst, spkr, redial,hold, msgs, xfer, and mute. Note: some of these are model dependent. For example, onkeystatus = function(){}.
onkeynum: This is a special catch all handler for number keys. It is called if onkey[specific_number] doesn't exist but this is set (any number key).
onkey: This is a special catch all handler for all keys. Any key press is called if the specific key doesn't exist and if not onkeynum and it was a number key.