How can I know if "Enter" is pressed in Text box?

While entering info into text box, how can I know if key “Enter” is pressed? Or any other non-printable key? I don’t need to see them, I want to start some other macro after key “Enter” is pressed.

Just check the key code. Attach to Key pressed (or released) event:

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

Other constants - click here.

Thank you so much. It works perfect.

If this answers your question please click on the :heavy_check_mark: (upper left area of answer).

In my opinion the non-formatting marks can’t be shown in a text box (shape).
For better control use text frames.

Nevertheless shapes are used as text boxes within other shapes (rectangles; circles…). But they seem to have other properties for inserted texts, they act like text frames. They show non printing marks.

Thank you, but I don’t need to see them. I want to call some other macro if Enter is pressed.