Remote Control Keypress and Key Codes

No replies

There's a pretty good article here on keypresses for JavaScript, and here's a list of the Key Codes. This is how you can make events happen in your plug-in and have them mapped to certain keys on the remote. Here's an example of assigning URI's to number keys using JavaScript:

function navigate(Event)// Event appears to be passed by Mozilla
{
var moveto;

// IE does not appear to pass it, so lets use global var
if(Event==null)
Event=event;

if(Event.type!='keyup')
return;

//alert("Code: "+Event.keyCode);

switch (Event.keyCode)
{
/*! Left key */
// case 37: moveto="prevpage.html"; break;

/*! Up key */
// case 38: moveto="index.html"; break;

/*! Right key */
// case 39: moveto="nextpage.html"; break;

/*! 1 key */
case 49:
moveto="SWF/BarnBaron.swf"; break;

/*! 2 key */
case 50:
moveto="SWF/game_blackjack.swf"; break;

/*! 3 key */
case 51:
moveto="SWF/CritterCrossing.swf"; break;

/*! 4 key */
case 52:
moveto="SWF/game_dawnofthefly.swf"; break;

/*! 5 key */
case 53:
moveto="SWF/FlashVegas.swf"; break;

/*! 6 key */
case 54:
moveto="SWF/HoleInOne.swf"; break;

/*! 7 key */
case 55:
moveto="SWF/LaunchFighters.swf"; break;

/*! 8 key */
case 56:
moveto="SWF/LogJam.swf"; break;

/*! 9 key */
case 57:
moveto="SWF/Tetris.swf"; break;

/*! 0 key */
// case 48:
// moveto="SWF/Tetris.swf"; break;

default: return;
}

document.location.href=moveto;
}

document.onkeyup=navigate;

AttachmentSize
20080122_flash-games.zip1.59 MB