
	// Lista de Teclas Actuales de ADB

	var VK_CONTROL	= 0x100;
	var VK_ALT		= 0x400;
	var KEY_UP 		= 0x26;
	var KEY_DOWN 	= 0x28;
	var KEY_LEFT	= 0x25;
	var KEY_RIGHT	= 0x27;
	var KEY_BACK 	= 0x79;
	var KEY_HOME 	= 0x78;
	var KEY_MENU	= 0x7b;
	var KEY_WWW		= 0x73;
	var KEY_TV		= 0x72;
	var KEY_HELP	= 0x70;
	var KEY_INFO 	= 0x70;		// ???
	var KEY_SELECT	= 0x7a;
	var KEY_TEXT    = 0x71;
	var KEY_LIST	= KEY_HOME | VK_CONTROL;

	var KEY_CHUP	= KEY_UP   | VK_ALT;
	var KEY_CHDN	= KEY_DOWN | VK_ALT;

	var KEY_PGUP	= KEY_UP   | VK_CONTROL;
	var KEY_PGDN	= KEY_DOWN | VK_CONTROL;

	var KEY_RED		= 0x74;
	var KEY_GREEN	= 0x75;
	var KEY_YELLOW	= 0x76;
	var KEY_BLUE	= 0x77;

	var KEY_PLAY	= 0x74 | VK_ALT;
	var KEY_PAUSE	= 0x77 | VK_ALT;
	var KEY_PLAYPAUSE=0x74 | VK_CONTROL;
	var KEY_STOP	= 0x77 | VK_CONTROL;
	var KEY_FWD		= 0x76 | VK_CONTROL;
	var KEY_RWD		= 0x75 | VK_CONTROL;

	//var KEY_FRWD	= KEY_LEFT  | VK_ALT;
	//var KEY_FFWD	= KEY_RIGHT | VK_ALT;
	var KEY_FRWD	= -10;
	var KEY_FFWD	= -20;

	var KEY_VOLUP	= 0x72 | VK_CONTROL;
	var KEY_VOLDN	= 0x71 | VK_CONTROL;
	var KEY_MUTE	= 0x73 | VK_CONTROL;

	var KEY_0		= 0x30;
	var KEY_1		= 0x31;
	var KEY_2		= 0x32;
	var KEY_3		= 0x33;
	var KEY_4		= 0x34;
	var KEY_5		= 0x35;
	var KEY_6		= 0x36;
	var KEY_7		= 0x37;
	var KEY_8		= 0x38;
	var KEY_9		= 0x39;

	var blocked = false;
	/////////////////////////////////////////////

	var KeyHandler=new Object();

	KeyHandler.handle=function(e) { return false; } //this.process(e.which,e); }
	KeyHandler.stopAutoRepeat=function() {}
	KeyHandler.init=function(e) {
		KeyHandler.input=ialEnv.input;
		try {
			KeyHandler.input.addEventListener(ialEnv.input.ON_KEY_DOWN, this.imgKeyListener);
		} catch (e) {
			alert ("Listener exception: "+e.description);
		}
	}

	KeyHandler.imgKeyListener = function (event) {
		var cod=event.extendedKeyCode;
		if(!blocked)
			try{KeyHandler.process( (cod&0x0fff0000)>>16, event);}catch(e){}
		else event.consume();
	}

	KeyHandler.init();

	/////////////////////////////////////////////

	// Returns hexadecimal value of a decimal given number
	function parseHex (num) {
		var hexValues = "0123456789abcdef"
		var aux = num; var aux2 = 0; var datos = ""; var result = "";
		while (aux >= 16) {
			aux2 = aux % 16
			aux = Math.floor (aux/16)
			datos += hexValues.charAt(aux2);
		}
		datos += hexValues.charAt(aux);					// datos queda con el hex en orden inverso
		
		var n = datos.length;
		for (i=0; i<=6; i++) {							// Poner el valor siempre en 6 cifras en orden
			if (i>n) result = 0 + result;
			else result += datos.substring (n-i-1, n-i);
		}

		for (i=0; i<result.length; i++) {				// Eliminar los ceros del número
			if (result.charAt(i) == '0') {result = result.substring (1); i--;}
			else break;
		}
		//return ("0x"+result);							// Si se quiere con 0x
		return (result);
	}


