I thought he was fairly straightforward in describing the solution (which is
nice by the way!).
var CtrlPressed = false;
// Do these in $(document).ready() method
$(document).keydown(function() { CtrlPressed = true; });
$(document).keyup(function() { CtrlPressed = false; });
In your click event, just do:
if (CtrlPressed == true)
{
// Do whatever
} else {
// Do whatever else
}
Completely untested but that should be enough to get you going.
Stefan Kilp [sk-software] wrote:
>
> Hi,
>
> do you have any sample code for me?
>
> thanks
> stefan
>
>> I have done it several times already in fact.
>>
>> What you have to do is add another global keydown event to the
>> document, in which you then have to check for e.ctrlKey and save the
>> boolean to a scoped variable your click event can access.
>> Now add another keyup event, were you set your boolean to false again.
>> That's it.
>>
>> Paul
>>
>> 2007/2/8, Stefan Kilp [sk-software] <[EMAIL PROTECTED]>:
>> > hi,
>> >
>> > is it possible to distinguish between a click with or without a
>> ctrl/alt key pressed.
>> >
>> >
>> > i want to simulate "selecting items" with Ctrl+click and click only to
>> execute an action.
>> >
>> >
>> > $("p").bind("click", function() {
>> >
>> > // how to find out what keys where pressed
>> > if (ctrl-pressed) {
>> > start select action
>> > }
>> > else {
>> > start normal action
>> > }
>> > })
>> >
>> >
>> > thanks
>> > stefan
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Stefan Kilp
>> > SK-Software, Entwicklung & Beratung
>> >
>> > email: [EMAIL PROTECTED]
>> >
>> > fon : +49 6151 93344-0
>> > fax : +49 6151 93344-20
>> > Herta-Mansbacher-Str. 98
>> > 64289 Darmstadt, Germany.
>> > -----------------------------------------------------
>> >
>> >
>> > _______________________________________________
>> > jQuery mailing list
>> > [email protected]
>> > http://jquery.com/discuss/
>> >
>>
>>
>> --
>> --
>> Paul Bakaus
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>
>
> --
> Stefan Kilp
> SK-Software, Entwicklung & Beratung
>
> email: [EMAIL PROTECTED]
>
> fon : +49 6151 93344-0
> fax : +49 6151 93344-20
> Herta-Mansbacher-Str. 98
> 64289 Darmstadt, Germany.
> -----------------------------------------------------
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/click-event-and-keyCode-tf3193539.html#a8872542
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/