We help IT Professionals succeed at work.
Get Started

Visual Basic 2010 How can I tell if the user stops pressing a key

LetchfordP
LetchfordP asked
on
221 Views
Last Modified: 2020-04-13
Hi all
I am using the code below and I just need a way of telling if the user has stopped pressing a key.
Have tried to use Key up  but I can not get it to work? please can you show me how I can do it Thanks
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean

           Select keyData
            Case Keys.Down
                key1 = Keys.Down
                If key2 <> key1 Then
                    Call tiltdown1()
                End If
                key2 = key1

            Case Keys.Up
                key1 = Keys.Up
                If key2 <> key1 Then
                    Call tiltup1()
                End If
                key2 = key1

            Case Keys.Right
                key1 = Keys.Right
                If key2 <> key1 Then
                    Call Panright1()
                End If
                key2 = key1

            Case Keys.Left
                key1 = Keys.Left
                If key2 <> key1 Then
                    Call Panleft1()
                End If
                key2 = key1

            Case Keys.M
                key1 = Keys.M
                If key2 <> key1 Then
                    Call zoomout1()
                End If
                key2 = key1

            Case Keys.N
                key1 = Keys.N
                If key2 <> key1 Then
                    Call zoomin1()
                End If
                key2 = key1

            Case Keys.S
                key1 = Keys.S
                If key2 <> key1 Then
                    Call allstop1()
                End If
                key2 = key1

        End Select
        Return temp(0)

    End Function

Open in new window

Comment
Watch Question
Top Expert 2015
Commented:
This problem has been solved!
Unlock 16 Answers and 29 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE