title: Building a typing game in C#
body: <p>a few days back i started reading Head first C#, i use visual c# 2015 for building code and learning C# but however the book is based on visual studio 2010, i never ran into any problem  so far while learning until i ran into this exercise when i have to build a typing game, i followed all the procedure as mentioned by the book and built it with no errors. but in the end when i run the code a key press from the keyboard should initialize the game but nothing seems t o start the game not even a mouse click or even from virtual keyboard.</p>
  
  <p><b>Here is the code</b></p>
  
  <pre><code>namespace WindowsFormsApplication15{
  public partial class Form1 : Form
  {
      Random random = new Random();
      Stats stats = new Stats();
      public Form1()
      {
          InitializeComponent();
      }
  
      private void timer1_Tick(object sender, EventArgs e)
      {
          listBox1.Items.Add((Keys)random.Next(65, 70));
          if (listBox1.Items.Count &gt; 7)
          {
              listBox1.Items.Clear();
              listBox1.Items.Add("Game over");
              timer1.Stop();
          }
      }
  
      private void Form1_KeyDown(object sender, KeyEventArgs e)
      {
          if  (listBox1.Items.Contains(e.KeyCode))
          {
              listBox1.Items.Remove(e.KeyCode);
              listBox1.Refresh();
              if (timer1.Interval &gt; 400)
                  timer1.Interval -= 10;
              if (timer1.Interval &gt; 250)
                  timer1.Interval -= 7;
              if (timer1.Interval &gt; 100)
                  timer1.Interval -= 2;
              difficultyProgressBar.Value = 800 - timer1.Interval;
  
              stats.Update(true);           
          }
          else
          {
              stats.Update(false);
          }
          correctLabel.Text = "Correct:" + stats.Correct;
          missedLabel.Text = "Missed:" + stats.Missed;
          totalLabel.Text = "Total:" + stats.Total;
          accuracyLabel.Text = "Accuracy:" + stats.Accuracy + "%";
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><b>class for the code</b></p>
  
  <pre><code>namespace WindowsFormsApplication15{
  class Stats
  {
      public int Total = 0;
      public int Missed = 0;
      public int Correct = 0;
      public int Accuracy = 0;
  
      public void Update(bool correctKey)
      {
          Total++;
          if (!correctKey)
          {
              Missed++;
          }
          else
          {
              Correct++;
          }
          Accuracy = 100 * Correct / (Missed + Correct);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><b>Form designer code</b></p>
  
  <pre><code>namespace WindowsFormsApplication15{
  partial class Form1
  {
      /// &lt;summary&gt;
      /// Required designer variable.
      /// &lt;/summary&gt;
      private System.ComponentModel.IContainer components = null;
  
      /// &lt;summary&gt;
      /// Clean up any resources being used.
      /// &lt;/summary&gt;
      /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;
      protected override void Dispose(bool disposing)
      {
          if (disposing &amp;&amp; (components != null))
          {
              components.Dispose();
          }
          base.Dispose(disposing);
      }
  
      #region Windows Form Designer generated code
  
      /// &lt;summary&gt;
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// &lt;/summary&gt;
      private void InitializeComponent()
      {
          this.components = new System.ComponentModel.Container();
          this.listBox1 = new System.Windows.Forms.ListBox();
          this.timer1 = new System.Windows.Forms.Timer(this.components);
          this.statusStrip1 = new System.Windows.Forms.StatusStrip();
          this.correctLabel = new System.Windows.Forms.ToolStripStatusLabel();
          this.missedLabel = new System.Windows.Forms.ToolStripStatusLabel();
          this.totalLabel = new System.Windows.Forms.ToolStripStatusLabel();
          this.accuracyLabel = new System.Windows.Forms.ToolStripStatusLabel();
          this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
          this.difficultyProgressBar = new System.Windows.Forms.ToolStripProgressBar();
          this.statusStrip1.SuspendLayout();
          this.SuspendLayout();
          // 
          // listBox1
          // 
          this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
          this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 80.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
          this.listBox1.FormattingEnabled = true;
          this.listBox1.ItemHeight = 120;
          this.listBox1.Location = new System.Drawing.Point(0, 0);
          this.listBox1.MultiColumn = true;
          this.listBox1.Name = "listBox1";
          this.listBox1.Size = new System.Drawing.Size(887, 261);
          this.listBox1.TabIndex = 0;
          // 
          // timer1
          // 
          this.timer1.Interval = 800;
          this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
          // 
          // statusStrip1
          // 
          this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
          this.correctLabel,
          this.missedLabel,
          this.totalLabel,
          this.accuracyLabel,
          this.toolStripStatusLabel1,
          this.difficultyProgressBar});
          this.statusStrip1.Location = new System.Drawing.Point(0, 239);
          this.statusStrip1.Name = "statusStrip1";
          this.statusStrip1.Size = new System.Drawing.Size(887, 22);
          this.statusStrip1.SizingGrip = false;
          this.statusStrip1.TabIndex = 1;
          this.statusStrip1.Text = "statusStrip1";
          // 
          // correctLabel
          // 
          this.correctLabel.Name = "correctLabel";
          this.correctLabel.Size = new System.Drawing.Size(58, 17);
          this.correctLabel.Text = "Correct: 0";
          // 
          // missedLabel
          // 
          this.missedLabel.Name = "missedLabel";
          this.missedLabel.Size = new System.Drawing.Size(56, 17);
          this.missedLabel.Text = "Missed: 0";
          // 
          // totalLabel
          // 
          this.totalLabel.Name = "totalLabel";
          this.totalLabel.Size = new System.Drawing.Size(45, 17);
          this.totalLabel.Text = "Total: 0";
          // 
          // accuracyLabel
          // 
          this.accuracyLabel.Name = "accuracyLabel";
          this.accuracyLabel.Size = new System.Drawing.Size(78, 17);
          this.accuracyLabel.Text = "Accuracy: 0%";
          // 
          // toolStripStatusLabel1
          // 
          this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
          this.toolStripStatusLabel1.Size = new System.Drawing.Size(533, 17);
          this.toolStripStatusLabel1.Spring = true;
          this.toolStripStatusLabel1.Text = "Difficulty";
          this.toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
          // 
          // difficultyProgressBar
          // 
          this.difficultyProgressBar.Name = "difficultyProgressBar";
          this.difficultyProgressBar.Size = new System.Drawing.Size(100, 16);
          // 
          // Form1
          // 
          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
          this.ClientSize = new System.Drawing.Size(887, 261);
          this.Controls.Add(this.statusStrip1);
          this.Controls.Add(this.listBox1);
          this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
          this.MaximizeBox = false;
          this.MinimizeBox = false;
          this.Name = "Form1";
          this.Text = "Form1";
          this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
          this.statusStrip1.ResumeLayout(false);
          this.statusStrip1.PerformLayout();
          this.ResumeLayout(false);
          this.PerformLayout();
  
      }
  
      #endregion
  
      private System.Windows.Forms.ListBox listBox1;
      private System.Windows.Forms.Timer timer1;
      private System.Windows.Forms.StatusStrip statusStrip1;
      private System.Windows.Forms.ToolStripStatusLabel correctLabel;
      private System.Windows.Forms.ToolStripStatusLabel missedLabel;
      private System.Windows.Forms.ToolStripStatusLabel totalLabel;
      private System.Windows.Forms.ToolStripStatusLabel accuracyLabel;
      private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
      private System.Windows.Forms.ToolStripProgressBar difficultyProgressBar;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I just started learning C# and working with visual studio this month, i don't know much about programming
  My guess is the problem lies some where with the  KeyDown event
  <a href="https://i.stack.imgur.com/BAtda.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BAtda.jpg" alt="enter image description here"></a></p>