Question : press 2 keys at once

I cant get an object to respond to 2 keys being presses at once in silverlight
Each to move diagonal up/right I press right and up key.
the issue is if i take my finger of the up key only i want the object to start just moving right, without having to take my finder off the right key. eg i hold 2 keys down and then just keep holding 1 key down.

currently the object stops moving if i take my finger off just 1 key if i have 2 keys held down.

Private Sub check_keys()
..
   If dict.ContainsKey(Key.Right) And dict.ContainsKey(Key.Up) Then

            myplayer.move(5)
        ElseIf dict.ContainsKey(Key.Right) And dict.ContainsKey(Key.Down) Then

            myplayer.move(6)

        ElseIf dict.ContainsKey(Key.Left) Then

            myplayer.move(1)

        ElseIf dict.ContainsKey(Key.Right) Then
            myplayer.move(2)
        ElseIf dict.ContainsKey(Key.Up) Then
            myplayer.move(3)
        ElseIf dict.ContainsKey(Key.Down) Then
            myplayer.move(4)
        ElseIf dict.ContainsKey(Key.Space) Then
            ' Canvas.SetTop(img, y - up)
        End If
..
 Private Sub getKeyup(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs)
 
  If dict.ContainsKey(Key.Left) Then
            dict.Remove(Key.Left)
        ElseIf dict.ContainsKey(Key.Right) Then
            dict.Remove(Key.Right)
endif
        If dict.ContainsKey(Key.Up) Then
            dict.Remove(Key.Up)
        ElseIf dict.ContainsKey(Key.Down) Then
            dict.Remove(Key.Down)
        End If
...
 Private Sub getKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs)


        If e.Key = Key.Up And Not dict.ContainsKey(Key.Up) Then
            dict.Add(Key.Up, True)
endif

   
        If e.Key = Key.Right And Not dict.ContainsKey(Key.Right) Then
            dict.Add(Key.Right, True)
      endif

Answer : press 2 keys at once

Private Sub getKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs)
    keyArray(e.Key) = True
End Sub

Private Sub getKeyup(ByVal sender As System.Object, ByVal e As System.Windows.Input.KeyEventArgs)
    keyArray(e.Key) = False
End Sub
Random Solutions  
 
programming4us programming4us