KeyPress Event Handller
How KeyPress Event is more useful in programming
KeyDown Event - When a key is Pressed and not yet Released, the code in this event is executed as soon as you press the any key or to the key to which the program is written.
KeyUp Event - When a key is released, but not when any key is pressed
=> meaning... when a key is pressed, no code works or executed, unless there is another piece of code writen for
KeyDown Event.
Key Press - When a key on the keyboard is pressed and relesed... ie., when a key is press and released immediately, and not after some time.
To summarise: Three keyboard events namely: KeyDown, KeyUp, KeyPress.
Please refer to chr() and asc() in excel or in access. This will help, to understand, what an ASCII (American Standard Code for Information and Interchange) code is and what does chr() and asc() are...
Event Handler:
Event handler is nothing more than a procedure/function. Events are executed
- either at user interaction with system or when a user presses a key on the keyboard (ie., on Mouse-Left-Button-click or Mouse-double-click-left-button.
Examples to Practice:
- Print only vowels in a given text box
- Print only consonents in a given text box
- Write code to convert each numeric character that is typed, to '*', just similar to password, ie., A text box should accept only numeric characters, also each numeric character that is keyed-in should be converted into '*'
- Write code to accept only first five alphabets and first five numbers and not any other character.
- Write code to accept only upper case letters and not lower case letters.
- Write code to accept only lower case letters, if the user types upper case letters, then the programme should automatically convert upper case letters into lower case letters and print in text box.
- Write code to print only special characters and none (eg: @@, #, $, %, ^, ...")
- Write code to covert any character to into special character.
All the content that you learn here will not be of any use, until you practice, so I urge you to practice. As and when you practice, you get more doubts as to how to go ahead, these doubts strengthen your knowledge and lead you to experience.