We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

Is there a function to take a single character from the keyboard? [closed]

asked 2015-04-24 16:55:41 +0200

riq.willitts gravatar image

Using a LibreOffice form containing a listbox, I can easily set up an event on the listbox to call a Basic macro when a key is released. However there does not seem to be any way for this macro to find out which key was pressed.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-20 17:04:46.306513

1 Answer

Sort by » oldest newest most voted

answered 2015-04-25 11:45:00 +0200

pierre-yves samyn gravatar image

Hi - You can do:

Sub InfoKey(oEvent)

dim sMsg as string

with oEvent
    sMsg = "Modifiers: " & .Modifiers & chr(13)
    sMsg = sMsg & "KeyCode: " & .KeyCode & chr(13)
    sMsg = sMsg & "KeyChar: " & .KeyChar & chr(13)
    sMsg = sMsg & "KeyFunc: " & .KeyFunc
end with

msgbox sMsg

End Sub

See API info.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-04-24 16:55:41 +0200

Seen: 72 times

Last updated: Apr 25 '15