How to get ALT, SHIFT and CTRL key?
-
Hi, I want to get ALT, SHIFT and CTRL key from keyboard. Is it possible in OnKeyDown event? How can I do it? Hope you can help me. Thanks.
-
Hi, I want to get ALT, SHIFT and CTRL key from keyboard. Is it possible in OnKeyDown event? How can I do it? Hope you can help me. Thanks.
-
OnSysKeyDown
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
Thanks for the reply. I think it's the same function as OnKeyDown(). Can I monitor SHIFT and CTRL with it?
-
Thanks for the reply. I think it's the same function as OnKeyDown(). Can I monitor SHIFT and CTRL with it?
-
Hi, I want to get ALT, SHIFT and CTRL key from keyboard. Is it possible in OnKeyDown event? How can I do it? Hope you can help me. Thanks.
`BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);`
This will help you to know the combination keydown tracking.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
-
`BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);`
This will help you to know the combination keydown tracking.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
Mahesh Kulkarni wrote:
BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);
though it is the nice way to get key state, but you have poll this thing every time to get state of the key.,
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
-
Mahesh Kulkarni wrote:
BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);
though it is the nice way to get key state, but you have poll this thing every time to get state of the key.,
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
Yes alok I do agree with u. But I got only this solution to do this....if any alternative for this please tell.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
-
`BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);`
This will help you to know the combination keydown tracking.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
Thank you for the reply. I will try this now.
-
`BOOL bCtrl = ::GetKeyState(VK_CONTROL); BOOL bAlt = ::GetKeyState(VK_SHIFT); BOOL bShift = ::GetKeyState(VK_MENU);`
This will help you to know the combination keydown tracking.
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
I tried your code inside OnKeyDown() event but the result is unpredictable. if(::GetKeyState(VK_CONTROL)) AfxMessageBox(L"CONTROL"); if(::GetKeyState(VK_SHIFT)) AfxMessageBox(L"SHIFT"); if(::GetKeyState(VK_MENU)) AfxMessageBox(L"ALT"); When ALT is pressed, either no display or wrong message(CONTROL or SHIFT) CONTROL and SHIFT sometimes correct but sometimes display all. Did i do something wrong? How will i use the code?
-
I tried your code inside OnKeyDown() event but the result is unpredictable. if(::GetKeyState(VK_CONTROL)) AfxMessageBox(L"CONTROL"); if(::GetKeyState(VK_SHIFT)) AfxMessageBox(L"SHIFT"); if(::GetKeyState(VK_MENU)) AfxMessageBox(L"ALT"); When ALT is pressed, either no display or wrong message(CONTROL or SHIFT) CONTROL and SHIFT sometimes correct but sometimes display all. Did i do something wrong? How will i use the code?
Try this...
BOOL bCtrl = ::GetKeyState(VK_CONTROL)& 0x8000; BOOL bShift = ::GetKeyState(VK_SHIFT)& 0x8000; BOOL bAlt = ::GetKeyState(VK_MENU)& 0x8000 ;
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.