B4J Question Track the pressing of the buttons F1-F12

red30

Well-Known Member
Licensed User
Longtime User
Can you please tell me how I can track the pressing of the buttons F1-F12 and use this event?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can also use GameViewHelper library for this.

B4X:
gvh.AddKeyListener("keylistener", MainForm)

Sub KeyListener_KeyPressed (KeyCode As String) As Boolean
   If KeyCode.Length = 2 And KeyCode.StartsWith("F") Then
     Log("Function pressed: " & KeyCode)
     Return True
   End If
   Return False
End Sub
 
Upvote 0

geps

Member
Licensed User
Longtime User
You can also use GameViewHelper library for this.

B4X:
gvh.AddKeyListener("keylistener", MainForm)

Sub KeyListener_KeyPressed (KeyCode As String) As Boolean
   If KeyCode.Length = 2 And KeyCode.StartsWith("F") Then
     Log("Function pressed: " & KeyCode)
     Return True
   End If
   Return False
End Sub
goes with arrows left up right down?
 
Upvote 0

geps

Member
Licensed User
Longtime User
goes with arrows left up right down?
Solved
If KeyCode.Length= 4 And KeyCode.StartsWith("L") Then 'Arrow left'
If KeyCode.Length= 5 And KeyCode.StartsWith("R") Then 'Arrow right'
If KeyCode.Length= 2 And KeyCode.StartsWith("U") Then 'Arrow up'
If KeyCode.Length= 4 And KeyCode.StartsWith("D") Then 'Arroe down'
 
Upvote 0
Top