title: C# - Console Keystrokes
body: <p>I want to compare the key pressed in a console to the left arrow key if they are equal meaning the key pressed was the left arrow key, key change the background color of the console to cyan...</p>
  
  <p>I'm not sure how to set up the If statement though, because I dont know how to compare keys in a console.</p>
  
  <pre><code>using System;
  
  namespace ConsolePaint
  {
  class MainClass
  {
  
  
      public static void Main (string[] args)
      {
          ConsoleKeyInfo keypress;
          keypress = Console.ReadKey(); // read keystrokes 
  
          if ( keypress.KeyChar == ConsoleKey.LeftArrow )
          {
              Console.BackgroundColor = "Cyan";
          }
      }
  }
  
  }
  </code></pre>