[Macros] How do I know which key has been pressed?

I want to know if left key, right key or tab key is pressed inside a textbox.

So I assign the event “non-alphanumeric input” on my textbox to my macro, but when I run my macro :

Sub KeyHandler_KeyPressed(oEvent)
    If oEvent.KeyCode = com.sun.star.awt.Key.TAB Then
        MsgBox("Tab key pressed")
    End If
End Sub

It shows an error dialog box stating that the object “oEvent” isnt defined

What am I doing wrong?

Hello,

Still have the same questions as asked on your previous post but not yet answered:

Please do not duplicate questions - you could just edit the question.

Yes but thought it was a dead question none would ever answer to. Didnt had any notification for your comment, sorry

Notifications don’t seem to be working correctly for some time now. Have reported this a few times. Still need answer.

Dead question is not an issue. You can edit the question, make a minor change & it will rise back to the top.