Note that there are some explanatory texts on larger screens.

plurals
  1. POKey down/up issue
    primarykey
    data
    text
    <p>here is my code:</p> <pre><code>namespace WindowsFormsApplication1 { public partial class Form1 : Form { Point lastClick; private Dictionary&lt;Keys, bool&gt; keyIsDown = new Dictionary&lt;Keys, bool&gt;(); private Timer timer; private int stream1; public Form1() { InitializeComponent(); keyIsDown.Add(Keys.D1, false); keyIsDown.Add(Keys.D2, false); keyIsDown.Add(Keys.D3, false); keyIsDown.Add(Keys.D4, false); keyIsDown.Add(Keys.A, false); keyIsDown.Add(Keys.S, false); keyIsDown.Add(Keys.D, false); keyIsDown.Add(Keys.F, false); keyIsDown.Add(Keys.Z, false); keyIsDown.Add(Keys.X, false); keyIsDown.Add(Keys.C, false); keyIsDown.Add(Keys.V, false); this.KeyPreview = true; } private void Form1_KeyDown(object sender, KeyEventArgs e) { if (true == keyIsDown.ContainsKey(e.KeyCode)) { keyIsDown[e.KeyCode] = true; } } private void Form1_KeyUp(object sender, KeyEventArgs e) { if (true == keyIsDown.ContainsKey(e.KeyCode)) { keyIsDown[e.KeyCode] = false; } } private void Form1_Load(object sender, EventArgs e) { // This makes the computer constantly call the playKeys method timer = new Timer(); timer.Interval = 10000; timer.Tick += new EventHandler(playKeys); timer.Enabled = true; } private void playKeys(Object source, EventArgs e) { if (true == keyIsDown[Keys.D1]) { Beat1.Image = Beatpadpc.Properties.Resources.white_square_button; } else { Beat1.Image = Beatpadpc.Properties.Resources.black_square_button; } if (true == keyIsDown[Keys.D2]) { Beat2.Image = Beatpadpc.Properties.Resources.white_square_button; } else { Beat2.Image = Beatpadpc.Properties.Resources.black_square_button; } } </code></pre> <p>And what happens is this: </p> <pre><code>Key D1 down = key D1 white. Key D1 up = nothing happens until timer os over. Key D2 down = Key D1 black. Key D2 up = nothing happens until timer is over. Key D1 down = Key D2 black... etc... Key D1 down + Key D2 down = Key D1 white + Key D2 white. Key D1 up + Key D2 up = Key D1 and D2 stays the same until timer is over. It should be: Key D1 down = Key D1 white. Key D1 up = Key D1 black. Key D2 down = Key D2 white. Key D2 up = Key D2 black. </code></pre> <p>(Even if both keys are down or up it shouldn't affect the behavior of the other key).</p> <p>What it should happen when key is up should be immediately after the key is up, it only happens when its down.</p> <p>How do i fix this?</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.
 

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