title: Count number of ENTER in TextBox after message selection in c#
body: <p>I am new to c#. I am learning graphic objects by doing a Hangman game.
  I need to save two char arrays : first from the word to be searched in <strong>word_selection_proposal()</strong>, second from the word suggested by the other player in <strong>word_selection_analysis()</strong>.</p>
  <p>I was thinking in using a boolean variable named <strong>first</strong> to ensure if that is the first time the function txtWord_KeyPress is called or not, to distinguish the first <strong>ENTER</strong> from the first player to the player who is searching for the word. I understand my boolean is a local variable so it is reset to true each time <strong>ENTER</strong> is pressed.</p>
  <p>Is there a possibility to count the number of times <strong>ENTER</strong> is pressed so then I can distinguish which function to call to save the arrays then I could save this data.</p>
  <p>Please, see just below the code and a picture to understand the code.
  <a href="https://i.stack.imgur.com/pyTJn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pyTJn.jpg" alt="btnWord" /></a>
  Thank you in advance</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  
  
  namespace Hangman_Game
  {
      public partial class Hangman : Form
      {
          public Hangman()
          {
              InitializeComponent();
          }
  
          private void Hangman_Load(object sender, EventArgs e)
          {
              FillComboLetters();
              comboLetters.Enabled = false;
              btnTest.Enabled = false;
              btnReplay.Enabled = false;
              lblVictory.Text = &quot;&quot;;
              txtWord.Text = &quot;Enter a word to search here&quot;;
              txtWord.Focus();
  
          }
  
          private void FillComboLetters()
          {
              comboLetters.Items.Clear();
  
              for (int k = 0; k &lt; 26; k++)
              {
                  comboLetters.Items.Add((char)('A' + k));
              }
  
              comboLetters.SelectedIndex = 0;
          }
  
          private void txtWord_Click(object sender, EventArgs e)
          {
              txtWord.Text = &quot;&quot;;
              txtWord.Focus();
          }
  
          private void txtWord_KeyPress(object sender, KeyPressEventArgs e)
          {
              Boolean first = true;
              string message = txtWord.Text.ToUpper();
              if ((e.KeyChar == (char) Keys.Enter) &amp;&amp; first)
              {
                  word_selection_proposal(message);
                  first = false;
              }
  
              if ((e.KeyChar == (char)Keys.Enter) &amp;&amp; !first)
              {
                  word_selection_analysis(message);
                  
              }
  
          }
  
          private void word_selection_proposal(string word)
          {
              char[] player1 = word.ToCharArray();
              txtWord.Text = &quot;Array copied, Now your turn&quot;;
          }
  
          private void word_selection_analysis(string word)
          {
              char[] player2 = word.ToCharArray();
              txtWord.Text = &quot;array copied&quot;;
              txtWord.Focus();
          }
  
      }
  }
  </code></pre>