With the InputListener class
out of the way, we can now look at the client application. The user interface
for this application consists solely of a textbox named tbStatus, of which its
multiline property is set to true. Double click on the form, and add the
following code to the Form_Load event.

privatevoid Form1_Load(object
sender, System.EventArgs e){InputListener inputListener = newInputListener();inputListener.OnMouseMove += newInputListener.MouseMoveHandler(
InputListener_MouseMove);inputListener.OnMouseButton += newInputListener.MouseButtonHandler(InputListener_MouseButton);inputListener.OnKeyPress += newInputListener.KeyPressHandler(InputListener_KeyPress);inputListener.Run();}The Form_Load event creates a new InputListener
Class, assigns functions to each one of its events, and then calls the Run
method to start the loop. You must now implement each one of the functions, and
have them output to the screen. The first one we shall code is the KeyPress
event handler. This displays the pressed key on-screen, and scrolls the text
window down to the bottom for readability. privatevoid InputListener_KeyPress( object sender,
KeyPressEventArgs e){if (e.ModifierKeys == Keys.Shift){tbStatus.Text += "Pressed Shift
& " +Convert.ToChar(e.KeyCode) +"\r\n";}else{tbStatus.Text += "Pressed
" + Convert.ToChar(e.KeyCode).ToString().ToLower() + "\r\n";}tbStatus.SelectionStart =
tbStatus.Text.Length;tbStatus.ScrollToCaret();}The same is done for the mouse button event handler.