-3

I've been trying to setup a windows application form with a simple function, I want to make my mouse pointer move down(from any position) as long as I have my "F" key holding. The moment I release "F", pointer should stop moving. So far I've managed to make my mouse pointer get in a position after pressing "F" but can't make my mouse to keep moving while holding the key.

Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
  • 1
    Can you share some code to show what you've tried? And what problems you've faced? – ainwood Aug 16 '17 at 22:46
  • Show us your method for this keypress and what you are trying to achieve. There are many ways to solve this but if its just a playful application i would just implement a timer and a checkflag: on keydown set a bool and start the timer to repeat your method and on keyup stop: [Here](https://stackoverflow.com/questions/4127270/c-sharp-how-to-loop-while-mouse-button-is-held-down) is Doggett's answer which you can adapt to keypresses. – user685590 Aug 16 '17 at 22:46

1 Answers1

0

I think you can use Keyboard.IsKeyDown(Key) method, so you can increase the position of mouse in the direction you want while the key is still down.

For MSDN Reference :

https://msdn.microsoft.com/en-us/library/system.windows.input.keyboard.iskeydown(v=vs.110).aspx

I hope it helps you, good luck !

Essam Fahmi
  • 1,920
  • 24
  • 31