0

I have a js function with a parammeter:

function dimension(id){
    val = {
    acMaximize : [
        ["#container", "100%", "90%"]
    ],
    acMinimize : [
        ["#container", "70%", "60%"]
    ],
};
var sub = val[id];
var sub1;
for(i in sub){
    sub1 = sub[i];
    $(sub1[0]).css({
        width : sub1[1],
        height : sub1[2]
    });
}
}

And I've tried calling this function in bind method:

$(document).bind("keydown", "Ctrl+A", dimension(id)); // <-- this didn't work.

How could I do this?

//Edit

Just in case of jQuery Hotkeys.

Lewis
  • 14,132
  • 12
  • 66
  • 87
  • 1
    Your question is not clear at all. Can you post a real world example? What kind of event is `param1` and what's `param2`?. Also `bind` is deprecated. – elclanrs Mar 15 '14 at 08:46
  • I'm sorry about that. I've just edited my question. Thanks for your response. – Lewis Mar 15 '14 at 08:49
  • It is still very unclear what you want to do. Would I be correct in saying you want `CTRL+A` to trigger the function `dimension()`? – ntzm Mar 15 '14 at 08:53
  • I've just edited again. ~~. – Lewis Mar 15 '14 at 08:56
  • I've found a previous question about detecting `CTRL+C` and `CTRL+V`, which you could modify to use `CTRL+A` [here](http://stackoverflow.com/questions/2903991/how-to-detect-ctrlv-ctrlc-using-javascript) – ntzm Mar 15 '14 at 08:57
  • Actually, it's not my concern. I just want to use a js function as a callback function of bind method. – Lewis Mar 15 '14 at 08:59
  • Since you can *only* use a JS function as the callback function, I don't see what the problem is. – Quentin Mar 15 '14 at 09:04
  • The point is, my method didn't work. – Lewis Mar 15 '14 at 09:10
  • Did you get any errors? (Check the console) – GolezTrol Mar 15 '14 at 09:12
  • The function runs when I use that code. It doesn't *do* anything because you are trying to loop over `undefined`, but it runs. – Quentin Mar 15 '14 at 09:15
  • I don't really get it. It returned error "Uncaught TypeError: Object Ctrl+A has no method 'apply' ". – Lewis Mar 15 '14 at 09:23

0 Answers0