detect shift, alt and ctrl keys

micro

Well-Known Member
Licensed User
Longtime User
hi to all,
how i can control the pressure of simultaneous keys "shift or ctrl or alt" with other keys with the library door?
The KeyPress event with door is the same as basic4ppc, I think I should use the KeyEventHandler for ceck all keys, is right?
And how can I use it?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the attached file.
B4X:
Sub Globals
    'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    object.New1(false)
    object.FromControl("textbox1")
    event.New1(object.Value,"KeyDown")
End Sub
Sub event_NewEvent
    object.Value = event.Data
    keys = object.GetProperty("Modifiers")
    If StrIndexOf("Alt",keys,0) > -1 Then 'handle alt
        form1.Text = "alt"
    End If
    If StrIndexOf("Shift",keys,0) > -1 Then 'handle shift
        form1.Text = "shift"
    End If
    If StrIndexOf("Control",keys,0) > -1 Then 'handle alt
        form1.Text = "control"
    End If
End Sub
 

Attachments

  • modifiers.sbp
    880 bytes · Views: 244

micro

Well-Known Member
Licensed User
Longtime User
ok Erel, it's work.
I added the event KeyUp to make null the variable keys.
What are the other properties of GetProperty than "Modifiers"?
Where can I find other features more detailed?
And if I want to capture the scan code (for all keys)?

Thanks
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…