These work (almost) universally in every application in MacOS, the only exception is text editors, which usually prefer their own key bindings.
Interestingly, these are all the same shortcuts you can use in the terminal (through readline), and are the standard key bindings for emacs.
Ctrl + a
: go to the beginning of the lineCtrl + e
: go to the end of the line