Trigger an event in Calc when the enter key is pressed in specific cells

I have searched and searched but cannot find the answer to a simple macro. I want to move the focus to a particular cell from the existing cell, depending on the value of the existing cell, after pressing the enter key.

You need use event content_changed in sheet, for example:

Sub cell_content_changed(source)

	address = source.AbsoluteName
	If address = "$Sheet1.$A$1" Then
		
		Select Case source.Value
			Case 1
				cell = source.Spreadsheet.getCellRangeByName("E1")
			Case 2
				cell = source.Spreadsheet.getCellRangeByName("E2")
		End Select
		ThisComponent.CurrentController.select(cell)
		
	End If
	
End Sub

Thanks for this. I am new to Libre but have experience with Excel. Can you help me with the syntax for “source” ? In Excel it would be “Private Sub Worksheet_Change(ByVal Target As Excel.Range)”. I’m afraid I cannot seem to get it right.