These worked for me:

(global-set-key (kbd "<home>") 'beginning-of-line)
(global-set-key (kbd "<end>") 'end-of-line)

I think you are more advanced with emacs than I am. But, I don't use the Home and End keys at all.

I just use:

  • Ctrl+a to bring the cursor to the home of the line.
  • Ctrl+e to bring the cursor to the end of the line.

  • Alt+SHIFT+, (C-<) to bring the cursor to the home of the file/buffer.

  • Alt+SHIFT+. (C->) to bring the cursor to the end of the file/buffer.

I learned these in the default emacs tutorial.

I suppose I only found those keys practical once I had, first, mastered touch typing.