Hi there,
I am a newbie as well. You might want to take a look at KONtx.utility.KeyHandler.map in the documentation at http://developer.yahoo.com/connectedtv/kon...idget_KONtx.pdf. Looks like you can have keydown events and you can recognize which keys are pressed based on the keyCode. I guess it should be possible via the application event handler for the event onWidgetKeyPress.
Thanks,
Vivek
The KONtx.utility.KeyHandler.map object maps to the value in the keyCode property of the event payload. It's a convenience so you as the developer don't have to worry about remembering what the actual number is. Of course, you don't have to use it.
Here's one way to capture keystrokes.
Subscribe to the application class in update view:
CODE
updateView: function() {
this._handleKeyPress.subscribeTo(KONtx.application, 'onWidgetKeyPress', this);
},
Define the view method that is listening for the onWidgetKeyPress event:
CODE
_handleKeyPress: function(event){
//NOTE if you're unsure of the value of keyCode you can log it to find out;
log("________________________________________________________________");
log("________________________________________________________________");
log(event.payload.keyCode);
log("________________________________________________________________");
log("________________________________________________________________");
switch(event.payload.keyCode) {
case 19:
//do something here;
break;
case 415:
//do something here;
break;
case KONtx.utility.KeyHandler.map.F10:
KONtx.HostEventManager.send("exitToDock");
break;
}
}
This should get you started. There's more to do, of course. For example, you should always unregister the listener when the view exits.
- Ben