Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In windows forms I would have a class that knows what the sequence is and holds the state of where you are in the sequence. Something like this should do it.</p> <pre><code>using System; using System.Collections.Generic; using System.Windows.Forms; namespace WindowsFormsApplication3 { public class KonamiSequence { List&lt;Keys&gt; Keys = new List&lt;Keys&gt;{System.Windows.Forms.Keys.Up, System.Windows.Forms.Keys.Up, System.Windows.Forms.Keys.Down, System.Windows.Forms.Keys.Down, System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, System.Windows.Forms.Keys.B, System.Windows.Forms.Keys.A}; private int mPosition = -1; public int Position { get { return mPosition; } private set { mPosition = value; } } public bool IsCompletedBy(Keys key) { if (Keys[Position + 1] == key) { // move to next Position++; } else if (Position == 1 &amp;&amp; key == System.Windows.Forms.Keys.Up) { // stay where we are } else if (Keys[0] == key) { // restart at 1st Position = 0; } else { // no match in sequence Position = -1; } if (Position == Keys.Count - 1) { Position = -1; return true; } return false; } } } </code></pre> <p>To use it, you would need something in your Form's code responding to key up events. Something like this should do it:</p> <pre><code> private KonamiSequence sequence = new KonamiSequence(); private void Form1_KeyUp(object sender, KeyEventArgs e) { if (sequence.IsCompletedBy(e.KeyCode)) { MessageBox.Show("KONAMI!!!"); } } </code></pre> <p>Hopefully that's enough to give you what you need. For WPF you will need slight differences is very similar (see edit history #1).</p> <p>EDIT: updated for winforms instead of wpf.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload