Hotkey = Class.create();
Hotkey.list = $A();
Hotkey.prototype = {
	character: null,
	action: function(){},
	initialize: function(character, action) {
		this.character = character;
		this.action = action;
	},
	matches: function(character) {
		return (this.character == character);
	}
}
Hotkey.add = function(character, action) {
	Hotkey.list.unshift(new Hotkey(character, action));
}
Hotkey.remove = function(character) {
	Hotkey.list.each(function(h,idx){
		if(h.character == character)
		  Hotkey.list.splice(idx, 1);
	});
}
Hotkey.process = function(event) {
  event = event || window.event;
  if (event) {
	  // Require modifier (Note: different by platform/browser) 
    if (event.ctrlKey || event.altKey || event.metaKey) {
      var code = event.charCode || event.which || event.keyCode;
      var character = String.fromCharCode(code).toLowerCase();
      if (event.shiftKey) character = character.toUpperCase();
      if(hotkey = Hotkey.list.detect(function(hk){ return hk.matches(character); }))
        hotkey.action();
    }
  }
}
