Control.IsKeyLocked(Keys) Método

Definição

Determina se a tecla CAPS LOCK, NUM LOCK ou SCROLL LOCK está ativada.

public:
 static bool IsKeyLocked(System::Windows::Forms::Keys keyVal);
public static bool IsKeyLocked (System.Windows.Forms.Keys keyVal);
static member IsKeyLocked : System.Windows.Forms.Keys -> bool
Public Shared Function IsKeyLocked (keyVal As Keys) As Boolean

Parâmetros

keyVal
Keys

O membro CAPS LOCK, NUM LOCK ou SCROLL LOCK da enumeração Keys.

Retornos

Boolean

true, se as teclas especificadas estiverem ativadas; caso contrário, false.

Exceções

O parâmetro keyVal se refere a uma chave que não seja a tecla CAPS LOCK, NUM LOCK ou SCROLL LOCK.

Exemplos

O exemplo de código a seguir exibe uma caixa de mensagem indicando se a chave especificada (a chave caps lock neste caso) está em vigor.

#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Windows::Forms;
int main()
{
   if (Control::IsKeyLocked( Keys::CapsLock )) {
      MessageBox::Show( "The Caps Lock key is ON." );
   }
   else { 
      MessageBox::Show( "The Caps Lock key is OFF." );
   }

}
using System;
using System.Windows.Forms;

public class CapsLockIndicator
{
    public static void Main()
    {
        if (Control.IsKeyLocked(Keys.CapsLock)) {
            MessageBox.Show("The Caps Lock key is ON.");
        }
        else {
            MessageBox.Show("The Caps Lock key is OFF.");
        }
    }
}

' To compile and run this sample from the command line, proceed as follows:
' vbc controliskeylocked.vb /r:System.Windows.Forms.dll /r:System.dll 
' /r:System.Data.dll /r:System.Drawing.dll

Imports System.Windows.Forms

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
End Class

Comentários

Use a IsKeyLocked propriedade para determinar se as teclas CAPS LOCK, NUM LOCK ou SCROLL LOCK estão ativadas, seja individualmente ou em combinação.

Aplica-se a