Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean 'handle your keys here End Function
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.A Then
Console.WriteLine("left")
Me.SuspendLayout()
If Not (Me.PictureBox1.Location.X) < 0 Then
Dim pt As Point = New Point(Me.PictureBox1.Location.X - 5, Me.PictureBox1.Location.Y)
Me.PictureBox1.Location = pt
End If
Me.ResumeLayout()
Return True
End If
If keyData = Keys.D Then
If Not (Me.PictureBox1.Location.X + Me.PictureBox1.Width) > Me.Width Then
Dim pt As Point = New Point(Me.PictureBox1.Location.X + 5, Me.PictureBox1.Location.Y)
Me.PictureBox1.Location = pt
End If
End If
If keyData = Keys.S Then
If Not (Me.PictureBox1.Location.Y) < 0 Then
Dim pt As Point = New Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 5)
Me.PictureBox1.Location = pt
End If
End If
If keyData = Keys.W Then
If Not (Me.PictureBox1.Location.Y) < 0 Then
Dim pt As Point = New Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 5)
Me.PictureBox1.Location = pt
End If
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function