RobertWHurst/KeyboardJS — Issue #20: Ability to register new key event mappings
Author: kimptoc
Created: 2012-02-25 08:39:18+00:00
State: open

Hi,

I am developing something using the Samsung Smart TV Javascript API - its based on a webkit browser.

http://www.samsungdforum.com/Guide/GuideList

The keyboard/remote handling uses custom event codes (defined in their API, in Common.API) for the keybinds, eg via things like this:

var tvKey = new Common.API.TVKeyValue();

then its used like this:

Main.keyDown = function()
{
var keyCode = event.keyCode;
alert("Key pressed: " + keyCode);

switch(keyCode)
{
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN:
alert("RETURN");
Player.stopVideo();
widgetAPI.sendReturnEvent();
break;
break;

case tvKey.KEY_PLAY:
alert("PLAY");

this.handlePlayKey();
break;
...

So, having used keyboardjs previously, I am thinking this is something quite similar to what it can handle.

Is there a way to register new key mappings (or plans to allow such?) I am thinking of a method to register a key like registerkey('play',tvKey.KEY_PLAY) which would add it to the current locale. Perhaps a version registerKeys that takes a map for registering several at once.

I can see that I could just create a new locale and add that - eg a 'tv' locale. It doesnt seem like the correct/best way - but given that (at least in my app), it will only be handling the remote control keys, it might be the best way forward.

Thanks,
Chris