2012-01-15 41 views

回答

1

如果您使用.NET 2.0或更高版本,可以使用Control.IsKeyLocked方法。

Imports System 
Imports System.Windows.Forms 
Imports Microsoft.VisualBasic 

Public Class CapsLockIndicator 

    Public Shared Sub Main() 
     If Control.IsKeyLocked(Keys.CapsLock) Then 
      MessageBox.Show("The Caps Lock key is ON.") 
     Else 
      MessageBox.Show("The Caps Lock key is OFF.") 
     End If 
    End Sub 'Main 

End Class 'CapsLockIndicator 
+0

這的確是。它是在.NET 2.0中引入的。 – 2012-01-15 07:54:13

+0

這非常適用:Control.IsKeyLocked(Keys.CapsLock)...我如何檢測是否雖是按住Shift鍵?這不起作用:Control.IsKeyLocked(Keys.LShiftKey) – 2012-01-15 22:03:03

+0

全部完成。這裏是代碼:(Control.ModifierKeys和Keys.Shift)= Keys.Shift – 2012-01-15 22:08:27

相關問題