Mouse & Keyboard Events in VB.Net
The events in a Visual Basic.Net program are of two types: user generated events and system generated events. The user-generated events occur when the user actions key press, clicks, mouse movements, etc. are happening. System generated events are the notifications in the computer.
An event in a program is an action which occurs when clicking on a button, typing some texts or moving the mouse and that calls a function or causing for another event.
Event Handling in VB.Net
VB.Net is an event optimized programming language, so it is called an event-driven programming language. I have already discussed the concept of event driven programming in Visual Basic.Net.
VB.Net mainly provide the following two events.
- Mouse Events
- Keyboard Events
VB.Net Mouse Events
Mouse events occur by the actions of the mouse in a Windows form, such as mouse move and mouse click. The following are the mouse events in Visual Basic.Net.
- MouseDown – occurs when a mouse button is pressed.
- MouseEnter – occurs when the mouse pointer enters the control.
- MouseHover – occurs when the mouse pointer hovers over the control
- MouseLeave – occurs when the mouse pointer leaves the control.
- MouseMove – occurs when the mouse pointer moves over the control.
- MouseUp – occurs when the mouse pointer is over the control, and the mouse button is released.
- MouseWheel – occurs when the mouse wheel moves and the control has the focus.
VB.Net Keyboard Events
Mouse events occur by the actions of the keyboard in a Windows form, such as key press and key up. The following are the keyboard events in Visual Basic.Net.
- KeyDown – occurs when a key is pressed down and the control has focus.
- KeyPress – occurs when a key is pressed and the control has focus.
- KeyUp – occurs when a key is released while the control has focus.