Board index » delphi » Detect ctrl-shift w/keyDown event handler?

Detect ctrl-shift w/keyDown event handler?

I'm just learning Delphi.  I'm forced to work in Delphi 1 because I need Win16
executables for the short term.

I'm trying to detect the difference between ctrl-tab and ctrl-shift-tab, and I
can't.  The "Shift" parameter of the keyDown event handler is of the type
TShiftState, which seeminly can only detect alt, ctrl, or shift but not
*combinations* of those keys.

How can I detect ctrl-shift (of for that matter alt-shift?

Thanks.
--
Carl Fink          ca...@dm.net
Manager, Dueling Modems Computer Forum    http://www.dm.net/

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

 

Re:Detect ctrl-shift w/keyDown event handler?


You can combine the keys like this:

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Shift = [ssShift,ssCtrl] then
    Edit1.Text := 'Shift-Control';
  if Shift = [ssShift,ssAlt] then
    Edit1.Text := 'Shift-Alt';
  if Shift = [ssCtrl,ssAlt] then
    Edit1.Text := 'Alt-Control';
  if Shift = [ssShift,ssAlt,ssCtrl] then
    Edit1.Text := 'Shift-Alt-Control';
end;

Finn Tolderlund

ca...@panix.com wrote in article <6n8m3n$m7...@nnrp1.dejanews.com>...

Quote
> I'm just learning Delphi.  I'm forced to work in Delphi 1 because I need
Win16
> executables for the short term.

> I'm trying to detect the difference between ctrl-tab and ctrl-shift-tab,
and I
> can't.  The "Shift" parameter of the keyDown event handler is of the type
> TShiftState, which seeminly can only detect alt, ctrl, or shift but not
> *combinations* of those keys.

> How can I detect ctrl-shift (of for that matter alt-shift?

> Thanks.
> --
> Carl Fink          ca...@dm.net
> Manager, Dueling Modems Computer Forum    http://www.dm.net/

> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Detect ctrl-shift w/keyDown event handler?


And this:

  if Shift = [] then
    Edit1.Text := ' None ';

Finn Tolderlund <xyNOJUMKMAILXYf...@teliamail.dkXYNOJUNKMAILxy> wrote in
article <01bda391$c71576e0$c2feffc2@default>...

Quote
> You can combine the keys like this:

> procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
>   Shift: TShiftState);
> begin
>   if Shift = [ssShift,ssCtrl] then
>     Edit1.Text := 'Shift-Control';
>   if Shift = [ssShift,ssAlt] then
>     Edit1.Text := 'Shift-Alt';
>   if Shift = [ssCtrl,ssAlt] then
>     Edit1.Text := 'Alt-Control';
>   if Shift = [ssShift,ssAlt,ssCtrl] then
>     Edit1.Text := 'Shift-Alt-Control';
> end;

> Finn Tolderlund

> ca...@panix.com wrote in article <6n8m3n$m7...@nnrp1.dejanews.com>...
> > I'm just learning Delphi.  I'm forced to work in Delphi 1 because I
need
> Win16
> > executables for the short term.

> > I'm trying to detect the difference between ctrl-tab and
ctrl-shift-tab,
> and I
> > can't.  The "Shift" parameter of the keyDown event handler is of the
type
> > TShiftState, which seeminly can only detect alt, ctrl, or shift but not
> > *combinations* of those keys.

> > How can I detect ctrl-shift (of for that matter alt-shift?

> > Thanks.
> > --
> > Carl Fink          ca...@dm.net
> > Manager, Dueling Modems Computer Forum    http://www.dm.net/

> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Detect ctrl-shift w/keyDown event handler?


isn't shiftstate a set of the 3.... and in that set there can be more than 1
item, so use
if (ssShift in theset) and (ssControl in theset)
or something of the liking

Roel

Quote
car...@panix.com wrote:

: I'm just learning Delphi.  I'm forced to work in Delphi 1 because I need Win16
: executables for the short term.

: I'm trying to detect the difference between ctrl-tab and ctrl-shift-tab, and I
: can't.  The "Shift" parameter of the keyDown event handler is of the type
: TShiftState, which seeminly can only detect alt, ctrl, or shift but not
: *combinations* of those keys.

: How can I detect ctrl-shift (of for that matter alt-shift?

: Thanks.
: --
: Carl Fink          ca...@dm.net
: Manager, Dueling Modems Computer Forum    http://www.dm.net/

: -----== Posted via Deja News, The Leader in Internet Discussion ==-----
: http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Detect ctrl-shift w/keyDown event handler?


Quote
In article <6n8m3n$m7...@nnrp1.dejanews.com>, ca...@panix.com writes:
>I'm trying to detect the difference between ctrl-tab and ctrl-shift-tab, and
>I
>can't.  The "Shift" parameter of the keyDown event handler is of the type
>TShiftState, which seeminly can only detect alt, ctrl, or shift but not
>*combinations* of those keys.

>How can I detect ctrl-shift (of for that matter alt-shift?

No, since TShiftState is a set it CAN contain both values.
Test by using the 'in' operator..e.g.
if (ssCtrl in Shift) and (ssShift in Shift) then....

regards
JP
John Parsons

Cray Chicken: Crosses faster than any other chicken, but if you don't dip it
in liquid nitrogen first, it arrives on the other side fully cooked!

Other Threads