Skip to content
Related Articles

Related Articles

C# | Check if Caps Lock is on or off through Console
  • Last Updated : 28 Jan, 2019

Given the normal Console in C#, the task is to check if the CAPS LOCK is on or off through Console.

Approach: This can be done using the CAPS LOCK property in the Console class of the System package in C#.

Program 1: When the CAPS LOCK is on




// C# program to illustrate the
// Console.CapsLock Property
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
  
namespace GFG {
  
class Program {
  
    static void Main(string[] args)
    {
  
        // Check if CAPS LOCK is on or off
        Console.WriteLine("Is CAPS LOCK on: {0}",
                               Console.CapsLock);
    }
}
}

Output:



Program 2: When the CAPS LOCK is off




// C# program to illustrate the
// Console.CapsLock Property
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
  
namespace GFG {
  
class Program {
  
    static void Main(string[] args)
    {
  
        // Check if CAPS LOCK is on or off
        Console.WriteLine("Is CAPS LOCK on: {0}",
                               Console.CapsLock);
    }
}
}

Output:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :