Check if a modifier key is pressed

ruimac

Member
When a button is pressed in a template, in Template Wizard, I would like to check if a modifier key (Shift, or Alt, or Ctrl) is being pressed, so that I could perform different actions. Is is possible to check for modifier keys being pressed inside the OnClick code?
 
You can try this code:
Code:
dim keyPressed

Sub TWUniButton1Click(Sender)
    select case keyPressed
        case 16
            msgBox "button pressed with shift"
        case 17
             msgBox "button pressed with ctrl"
        case 18
             msgBox "button pressed with alt"
        case else
             msgBox "button pressed with no key"
    end select

    keyPressed = 0
End sub


Function SC_KeyDown(Key, Shift)
        keyPressed = key
        SC_KeyDown = 0
End Function

Just consider that this code worked for me only in the Director and not in VTW or ActiveX
 
You can try this code:
Code:
dim keyPressed

Sub TWUniButton1Click(Sender)
    select case keyPressed
        case 16
            msgBox "button pressed with shift"
        case 17
             msgBox "button pressed with ctrl"
        case 18
             msgBox "button pressed with alt"
        case else
             msgBox "button pressed with no key"
    end select

    keyPressed = 0
End sub


Function SC_KeyDown(Key, Shift)
        keyPressed = key
        SC_KeyDown = 0
End Function

Just consider that this code worked for me only in the Director and not in VTW or ActiveX

Thank you so much. It worked great.
Actually, I was trying to do something similar, but I was only testing it in VTW, so it never worked. I see that it only works in Director.
 
Back
Top