Switch actions of Shift+Enter and Enter in notebook interface?

Using Autohotkey the following works pretty well.

#IfWinActive ahk_class NotebookFrame
  Enter::Send {blind}{shift down}{enter}{shift up} 
  Shift & Enter::Send {enter}
#IfWinActive

In case the internals are ever changed you can use the following to get the internal class.

Return::
  WinGetClass, class, A
  MsgBox, The active window's class is "%class%".
  return

This piece of code should do the trick. It takes effect immediately.

SetOptions[$FrontEnd, 
  FrontEndEventActions:>{{"MenuCommand", "HandleShiftReturn"} :> 
  FrontEndTokenExecute["Linebreak"], "ReturnKeyDown" :> 
FrontEndTokenExecute["EvaluateCells"]}]

(Tested on ArchLinux/MacOS_Sierra/Win10Server2016 with MMA 11. Hopefully it will work on Ubuntu, too)

If you want to run it automatically each time you open MMA, you can modify the code and insert it to the frontend configuration file $UserBaseDirectory/FrontEnd/init.m

And many thanks to Kuba. The comment under his answer inspired me a lot. Without his idea I wouldn't be able to produce this answer.


First move KeyEventTranslations.tr file to your $UserBaseDirectory in order to not damage installation files. (Rebinding keys to define new keyboard shortcuts)

Open the file and find those lines:

...

(* Evaluation *)

...

Item[KeyEvent["Return", Modifiers -> {Shift}], "HandleShiftReturn"]

...

(* Input *)

Item[KeyEvent["Return"], "Linebreak"]

...

and swap "HandleShiftReturn" with "Linebreak".

Works on Windows.