Control.IsKeyLocked(Keys) Método

Definição

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

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 Keys enumeração.

Devoluções

true se a chave ou chaves especificadas estiverem em vigor; caso contrário, false.

Exceções

O keyVal parâmetro refere-se a uma chave diferente das teclas CAPS LOCK, NUM LOCK ou SCROLL LOCK.

Exemplos

O exemplo de código seguinte mostra uma caixa de mensagem que indica se a chave especificada (a tecla Caps Lock, neste caso) está em efeito.

#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

Observações

Use o IsKeyLocked(Keys) método para determinar se as teclas CAPS LOCK, NUM LOCK ou SCROLL LOCK estão ativadas, individualmente ou em combinação.

Aplica-se a