Trapping key presses

Hi!

I want to write a windows service that can disable certain keys when pressed before they get into a program.

For example the delete key on my keyboard is broken and repeatedly presses itself.
Is there a way that I can trap the keypress and have it do nothing in effect disabling the key


Answer this question

Trapping key presses

  • Artie Sluka

    Have you thought of getting a new keyboard ;-)

    Seriously, if you were to attempt this (assuming you have good intentions here), you couldnt achieve it using the .NET framework - the only way I know of is to use a global hook (which is very unfriendly to the perf of your system) - and is not supported by the .NET Framework, as it doesnt support DLLExport.

    More details:
    http://support.microsoft.com/default.aspx scid=kb;EN-US;318804

    -Jessica

  • Trapping key presses