How does a device driver work?

Start talking. I need to write one, and i know nothing. Wikipedia/Howstuffworks was no help.

I need it so that a button connected the a USB port will activate something onscreen when pushed. The onscreen item isn’t important, nor is the language, really. I just need to have a basic gist of how they operate, and i’ll figure it out.

My though so far is to have the application create a blank file, open it when the button is pressed, save a character in the file to represent that the button was pressed, then have the requesting application open the file again and check to see if the button was pressed. That may be off though.