Board index » delphi » left and right Ctrl/Alt/Shift - Key

left and right Ctrl/Alt/Shift - Key

I've got a problem:
I want to write a procedure which  detects the key pressed by the user. So far
so good, but I want to know if it was the right or left (Ctrl, Shift, Alt) -
Key.
I have searched in the Help Files for the virtual Keys, and found:

vKey

Specifies one of 256 possible virtual-key codes.  
Windows NT: You can use left- and right-distinguishing constants to specify
certain keys. See the Remarks section for further information.
Windows 95: Windows 95 does not support the left- and right-distinguishing
constants available on Windows NT.

I am working with D2 and Win95, is there an other possibility to seperate the
two Ctrl, Shift and Alt keys? Can anybody help me?? Eventually with an short
Code example like:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
        case Key of
            VK_Left: showmessage('left');
            VK_Right: showmessage('right');
            VK_F10: showmessage('F10');
            VK_TAB: showmessage('Tab');
            VK_SHIFT: showmessage('Shift');
            VK_CONTROL: showmessage('CONTROL');
            VK_RCONTROL: showmessage('VK_RCONTROL'); // that does not work in
Win 95!!
            VK_LSHIFT: showmessage('VK_LSHIF'); // that does not work in Win
95!!
            VK_RSHIFT: showmessage('VK_RSHIFT'); // that does not work in Win
95!!
        end;
end;

Thank you very much.
Martin.

 

Re:left and right Ctrl/Alt/Shift - Key


You can separate Right Shift and Left Shift by reading the SCANCODE of the
key (for example, by intercepting wm_keydown - see Win32.HLP). For
WM_KeyDown, see bits 16-23 of the lKeyData - it is scancode. And what is bit
24 - I dunno, but maybe it enables to distinguish right and left Ctrl/Alt?
Try to experiment with it. Btw, the scancodes are - $36 for the Right Shift
and $2A for the Left Shift.

Greetings, Jevgenij Gorbunov

Aschweitz D??? ???Y??
<1998041821150100.RAA23...@ladder01.news.aol.com> ...

Quote
>I've got a problem:
>I want to write a procedure which  detects the key pressed by the user. So
far
>so good, but I want to know if it was the right or left (Ctrl, Shift,
Alt) -
>Key.

Other Threads