Handling command key on macs in events

217 visualitzacions
Ves al primer missatge no llegit

bootle

no llegida,
25 de jul. 2010, 18:26:4425/7/10
a MooTools Users
Hey guys,

I have an interface that uses ajax to load internal links, but also
want to enable control/command-click when someone wants to open the
link in a new tab.
There's an event property event.control which works fine on windows,
but for the command key I had to add something like:

var cmdown = false;

window.addEvent('keydown', function(e){
if(e.code == 224){
cmdown = true;
}
});
window.addEvent('keyup', function(e){
if(e.code == 224){
cmdown = false;
}
});

Now, is there a better / native way to handle this?

Maybe just event.control should also == true when command is pressed?

Cheers

Aaron Newton

no llegida,
25 de jul. 2010, 20:25:4925/7/10
a mootool...@googlegroups.com
event.meta is the mac key. so do if (event.meta || event.control) ...

bootle

no llegida,
26 de jul. 2010, 7:50:5826/7/10
a MooTools Users
Ok, I didn't know command is an equivalent of meta key, good to know

Thanks!
Respon a tots
Respon a l'autor
Reenvia
0 missatges nous