Click here to Skip to main content
15,886,689 members
Articles / Desktop Programming / Windows Forms

Low-level Windows API hooks from C# to stop unwanted keystrokes

Rate me:
Please Sign up or sign in to vote.
4.89/5 (88 votes)
26 Mar 200712 min read 602.8K   19.8K   231  
Babies and other animals love nothing better than to have a whack at the keyboard, with all sorts of unpredictable results. This application demonstrates how to trap keystrokes before they can do any damage.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings>
		<!-- Parameter to pass to KeyboardHook constructor. 
			Possible values: None, AllowAltTab, AllowWindowsKey, 
			AllowAltTabAndWindows, PassAllKeysToNextApp -->
		<add key="KeyboardHookConfig" value="None"/>

		<!-- What to display for each keystroke (from DrawShapes.ShapeType enum)
			Possible values: Text, Circles, Squares or Random -->
		<add key="DisplayConfig" value="Random"/>
		
	</appSettings>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
United Kingdom United Kingdom
Emma's first steps in programming took place at primary school over thirty years ago, thanks to a TI-99/4A and the LOGO language. Following a Master's degree in English Studies (obtained, strangely enough, with a paper on the birth of the microcomputer), Emma started her career in IT.

Over the last ten years, she has worked as a localiser, technical writer, editor, web designer, systems administrator, team leader and support engineer, before finally making the move into software development a few years ago. She is now thrilled on a daily basis that she is getting paid for writing code after doing it for free half her life!

Comments and Discussions