Firefox Key Press Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wangers16
    New Member
    • Jul 2007
    • 57

    Firefox Key Press Problem

    Hi

    I have the following code in my site, however it is currently not working in firefox could someone please tell me why, thanks in advance

    Code:
    function buttonpress(button) {
    var key = new Array(); 
    key['-'] = "javascript:AddItem()";
    isNetscape=(document.layers);
    eventChooser = (isNetscape) ? button.which : event.keyCode;
    which = String.fromCharCode(eventChooser).toLowerCase();
    for (var i in key) if (which == i) window.location = key[i];
    }
    document.onkeypress = buttonpress;
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    Hard to say what you are trying to do,
    but this will log the lower cased keystrokes to an array

    [CODE=javascript]function getKeypress(e){
    e= window.event || e;
    var k= e.charCode || e.keyCode;
    var which= String.fromChar Code(k).toLower Case();
    keyLog.push(whi ch);
    }
    window.keyLog=[];

    document.onkeyp ress= getKeypress;
    //test
    document.ondblc lick=function() {alert(keyLog)} ;[/CODE]

    Comment

    • wangers16
      New Member
      • Jul 2007
      • 57

      #3
      this peice of code is the key that is used to add a note on the site when pressed

      Code:
      key['-'] = "javascript:AddItem()";

      Comment

      Working...