1

I'm working on a framework for making games and i have a function for taking key input.

But since its a framework specific options need to be optional an example would be if you want movement by arrow keys, 'aswd' or maybe even mouse but if you want to use mouse you don't want to have arrow keys activated

so what i need to do is add if statements to the function after its declared.

The function:

Note: there is nothing wrong with the function it works fine

var key = [];
onkeydown = onkeyup = function(e){
    e = e || even;
    key[e.keyCode] = e.type == 'keydown';
    //insert here
};

Is there i can add this:

to the place where it says //insert here

if(map[17] && map[16] && map[65]){ // CTRL+SHIFT+A
    alert('Control Shift A');
}

Help would be much appreciated.

  • possible duplicate of [Javascript object extending -](http://stackoverflow.com/questions/10430279/javascript-object-extending) – agconti Feb 26 '15 at 17:15
  • 1
    I'd say he just look at: [Adding code to a javascript function programatically](http://stackoverflow.com/questions/9134686/adding-code-to-a-javascript-function-programatically) since it's a bit more to the point – basher Feb 26 '15 at 17:17
  • which one of 'onkeydown' and 'onkeyup' should i apply this to? @basher – jonas kjellerup Feb 26 '15 at 17:22

0 Answers0