PDA

View Full Version : Continuous check of keyboard.shiftPressed


scrimski
05-31-2008, 03:12 PM
Title say it pretty much:

How do I get a continuous check for the state of the Shift key?
Any pointers, links, tips are appreciated.

Thanks in advance and a nice weekend to everyone

magicm
05-31-2008, 03:59 PM
The only way I can think of is by using a .NET form with .KeyPreview set to true. Add an event handler for KeyDown and check the state of the shift key in your event function.

Hope this helps,
Martijn

scrimski
05-31-2008, 04:05 PM
Will try that, thank you.

Any other ideas?

magicm
05-31-2008, 05:08 PM
I'm sure there's other ways to go about this. Could you explain what you need this functionality for? Will it run in a dialog/floater?

Martijn

scrimski
05-31-2008, 05:16 PM
I'm trying to script a function to pan in 3ds Max like in PS a.k.a when the Space bar is pressed, you pan around, when released - not.

scorpion007
06-02-2008, 06:40 AM
I'd suggest against continuously polling -- instead, set a flag when the key is pressed, and unset it when it's released.

Polling is bad.

magicm
06-02-2008, 08:15 AM
I'd suggest against continuously polling -- instead, set a flag when the key is pressed, and unset it when it's released.

Polling is bad.

Agreed, but Skrimski's question remains, how do you know when the key is pressed?

scrimski
06-02-2008, 08:45 AM
The only way I can think of is by using a .NET form with .KeyPreview set to true. Add an event handler for KeyDown and check the state of the shift key in your event function.

Could you explain this a bit more? Never used dotNET before, so I'm a bit lost.
Same question for the continous polling.

CGTalk Moderation
06-02-2008, 08:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.