It can be done using javascript as well as vbscript however vbscript is only supported by IE, so I would suggest using javascript.
If you want to check if a key has been pressed on the form field you would do something like this
<input type="text" name="name" id="name" value="" onKeyPress="javascriptfunction();">
The funcion will be executed for each keypress, there are also other events like onkeyup - do a search on google for some examples.