[Basic] An easy way to cancel keypress

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
martinbrait
Posts: 6
Joined: Fri Apr 26, 2013 9:15 am

[Basic] An easy way to cancel keypress

Post by martinbrait »

Hello !

I am looking for an easy way to cancel keyboard,
when some keys that I choose are pressed.
In other words, i am looking for the way to
write "null" when i am pressing a character key.
Do you have an idea to do this ?

Code: Select all


'Intercepter l'appui sur une touche 

Sub KeyPressed_original(Event As Object)
 
   Dim Msg As String
 
   Select Case Event.KeyCode
   Case com.sun.star.awt.Key.RETURN
     Msg = "Return pressed"
   Case com.sun.star.awt.Key.TAB
     Msg = "Tab pressed"
   Case com.sun.star.awt.Key.DELETE
     Msg = "Delete pressed"
   Case com.sun.star.awt.Key.ESCAPE
     Msg = "Escape pressed"
   Case com.sun.star.awt.Key.DOWN
     Msg = "Down pressed"
   Case com.sun.star.awt.Key.UP
     Msg = "Up pressed"
   Case com.sun.star.awt.Key.LEFT
     Msg = "Left pressed"
   Case com.sun.star.awt.Key.RIGHT
     Msg = "Right pressed"
   Case Else
     Msg = "Character " & Event.KeyChar & " entered"
   End Select
 
End Sub

Thanks, guys !
LibreOffice 3.6.2 on Windows7
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Basic] An easy way to cancel keypress

Post by JeJe »

Use a keyhandler... put that word in the Search box for more information...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply