Button "pressed" animation by key

Doggo120

Newcomer
Joined
Oct 7, 2011
Messages
23
Location
Colombia
Its me again!

I was trying to find everywhere how to hold down some key (for example, "M") and animate a Button so that it looks that it's "pressed". When I release "M" then the button will be released as well (as if I have clicked the button with the key)

Button.PerformClick does not show this. In VB6 there was a Value property, which made this possible...

Thanks!!!
 
Re: Altering Button down state ("pressed") with key

Have you tried:
Code:
Private Sub Button1_KeyDown(ByVal sender As Object, _
   ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown
       If e.KeyCode = Keys.M Then
         'MsgBox("do something")
         e.Handled = True
         Button1.FlatStyle = FlatStyle.Flat
       End If
End Sub

Private Sub Button1_KeyUp(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyUp
       e.Handled = True
       Button1.FlatStyle = FlatStyle.Standard
End Sub
 
Re: Altering Button down state ("pressed") with key

Ok, I tried it... it's ok, but I would like to see the 'real' button pressed state (because it changes very drastically from a Button to a square)
 
Re: Altering Button down state ("pressed") with key

You could use a CheckBox control, setting the Appearance property to "Button." It will look like a normal button, but when the Checked property is set to true, the button will appear to be pressed in.

You might want to set AutoCheck to false. Otherwise the button will toggle between pushed and raised when the user clicks on it.
 
Back
Top