Control.IsKeyLocked(Keys) Control.IsKeyLocked(Keys) Control.IsKeyLocked(Keys) Control.IsKeyLocked(Keys) Method

Definición

Determina si la tecla BLOQ MAYÚS, BLOQ NUM o BLOQ DESPL está en vigor.Determines whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK key is in effect.

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 Keys Keys Keys

El miembro BLOQ MAYÚS, BLOQ NUM o BLOQ DESPL de la enumeración Keys.The CAPS LOCK, NUM LOCK, or SCROLL LOCK member of the Keys enumeration.

Devoluciones

Es true si la tecla o las teclas especificadas están en vigor; de lo contrario, es false.true if the specified key or keys are in effect; otherwise, false.

Excepciones

El parámetro keyVal hace referencia una tecla distinta de BLOQ MAYÚS, BLOQ NUM o BLOQ DESPL.The keyVal parameter refers to a key other than the CAPS LOCK, NUM LOCK, or SCROLL LOCK key.

Ejemplos

En el ejemplo de código siguiente se muestra un cuadro de mensaje que indica si la clave especificada (la tecla Bloq Mayús en este caso) está en vigor.The following code example displays a message box indicating whether the specified key (the Caps Lock key in this case) is in effect.

#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 'CapsLockIndicator

Comentarios

Utilice la IsKeyLocked propiedad para determinar si las teclas Bloq Mayús, Bloq Num o Bloq Despl están activadas, ya sea individualmente o en combinación.Use the IsKeyLocked property to determine whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK keys are on, whether individually or in combination.

Se aplica a