I would love to see a jQuery plugin that handles the browser-specific
retrieval of the key events, translates them into the keycodes, and does the
test for a specific combination for you behind the scenes. I'm imagining
usage something like this:
$().keycommand({'control','s'}, function() {
// what you want control-s to do.
});
Maybe you should be able to specify the event:
$().keycommand({'control','s'}, 'keydown', function() {
// what you want control-s to do.
});
Or, be able to do all your key bindings in a single hash, like:
$().keycommands({
{'control','s'}: function(){ // custom save },
{'control','z'}: function(){ // custom undo }
});
Possible? Anyone done something like this?
Cheers,
Jason
Blair McKenzie-2 wrote:
>
> I've found that I've had to add keydown to both document and body in order
> to detect ctrl and shift in both ie and ff.\
> $(document).add("body").keydown( function(e) {
> var ctrl = e.keyCode == 16 || e.ctrlKey;
> var alt = e.keyCode == 18 || e.altKey;
> });
>
> Blair
>
>
> On 10/5/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>>
>> Sam Collett schrieb:
>> > In IE:
>> > e.keyCode returns the same as e.charCode in Firefox
>> > The keys keyCode detects in Firefox are not detected at all in IE (so
>> > you cannot prevent copy/paste in text boxes for example)
>>
>>
>> Sam, if you need that, maybe you can use oncopy/onbeforecopy in IE for
>> that...
>>
>>
>> -- Klaus
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Capturing-modifier-key-events-tf2385678.html#a8552471
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/