Ctrl+Enter in Calc

I’d like if possible to have the Enter key work as it does in Writer, without the Ctrl key - to just go down to the next line of text or imput, rather than moving to the next cell. Is this possible?

Many thanks

no, it is impossible

Hello,

To do this requires some macro coding; more specifically a key handler. To accomplish your needs I combined a key handler I have previously used with a key initiator (last two subs) from answer by @librebel on this post → Create a macro that press “Enter” automatic once using a slight modification to Modifiers setting. Here are all macros required:

    Option Explicit

global oXKeyHandler as object

sub sStartXKeyHandler
    if isNull(oXKeyHandler) then
        oXKeyHandler = CreateUnoListener("KeyHandler_", "com.sun.star.awt.XKeyHandler")
        ThisComponent.CurrentController.AddKeyHandler(oXKeyHandler)
    endif
end sub

sub sStopXKeyHandler
    if not IsNull(oXKeyHandler) then 'only if still running'
        ThisComponent.CurrentController.removeKeyHandler(oXKeyHandler)
        oXKeyHandler = Nothing 'To know later this handler has stopped.'
    end if
end sub

sub XKeyHandler_Disposing(oEvent)
end sub

function KeyHandler_KeyPressed(oEvent) as boolean
REM The entire objective of the key handler:
REM On the menu, when the 'Enter' key is pressed
REM do not move to the next field(cancel)
	If oEvent.KeyCode = 1280 and oEvent.Modifiers = 0 Then
        simulate_KeyPress_RETURN
        KeyHandler_KeyPressed = True
	Else
        KeyHandler_KeyPressed = False 
	End If
End function

function KeyHandler_KeyReleased(oEvent) as boolean
REM but when the 'Enter' key is released,
REM execute the 'Key Released' event assigned in the control
	If oEvent.KeyCode = 1280 and oEvent.Modifiers = 0 Then
        KeyHandler_KeyReleased = False
    Else
	    KeyHandler_KeyReleased = True
   End If
end function

Sub simulate_KeyPress_RETURN()
  REM Simulate a RETURN Key press ( and -release ) in the current Window.
  REM NB. This can cause the triggering of window elements.
    Dim oKeyEvent As New com.sun.star.awt.KeyEvent
    oKeyEvent.Modifiers = 2     REM A combination of com.sun.star.awt.KeyModifier.
    oKeyEvent.KeyCode   = com.sun.star.awt.Key.RETURN               REM 1280.
    simulate_KeyPress( oKeyEvent )
End Sub

Sub simulate_KeyPress( oKeyEvent As com.sun.star.awt.KeyEvent )
REM Simulate a Key press ( and -release ) in the current Window.
REM NB. This can cause the triggering of window elements.
REM For example if there is a button currently selected in your form, and you call this method
REM while passing the KeyEvent for RETURN, then that button will be activated.
    If Not IsNull( oKeyEvent ) Then
        Dim oWindow As Object, oToolkit As Object
        oWindow = ThisComponent.CurrentController.Frame.getContainerWindow()
        oKeyEvent.Source = oWindow      
        oToolkit = oWindow.getToolkit()         REM com.sun.star.awt.Toolkit
        oToolkit.keyPress( oKeyEvent )          REM methods of XToolkitRobot.
        oToolkit.keyRelease( oKeyEvent )
    End If
End Sub

Once the code is copied into the documents macro area (system or document area) the handler needs to be started and stopped. The routine to start is sStartXKeyHandler and the routine to stop is sStopXKeyHandler. You can attach this to toolbar items or customize the form with OpenDocument and Document is going to be closed events. See LO documentation for more info on macros → Documentation/Publications.

To further help, attached is a sample with code for document installed. Toolbar is set so you can start & stop the key handler.

KeyHandler.ods (12.8 KB) - removed MRI code.

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.