Cek Status Tombol CapsLock, NumLock dan ScrollLock

Pada VB.NET untuk melakukan pengecekan apakah tombol CapsLock, Numlock dan ScrollLock dalam posisi On atau Off bisa dilakukan dengan mudah dengan memanfaatkan namespace My yang sudah disediakan.

Berikut ini contoh pengecekan tersebut dalam VB.NET, ketikkan source code pada event form keydown:

Public Class Form1
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
LBL_CAPSLOCK.Text = IIf(My.Computer.Keyboard.CapsLock = True, "ON", "OFF")
LBL_NUMLOCK.Text = IIf(My.Computer.Keyboard.NumLock = True, "ON", "OFF")
LBL_SCROOLLOCK.Text = IIf(My.Computer.Keyboard.ScrollLock = True, "ON", "OFF")
End Sub
End Class

Hasilnya:

Image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: