Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void MainForm_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyCode)
                {
                    case Keys.Up:
                        Engine.GearUp();
                        break;

...


While engine.gearup() is working, I need to cancel(or do something else i am not really sure about it) keydown event so user can not be able to press anymore keys until gearup() has done it's work

I tried e.handled and e.SuppressKeyPress and it didnt work for me ..Googled a bit and couldnt find anything..Any help will be appreciated
Posted

1 solution

Not tested, but instead of handling the event, try overriding the method that raises the event OnKeyDown and only calling base.OnKeyDown when you want to allow the key press.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900