Instead of having to keep track of the keys in the keymap, let the macro handle it. Add `beginning-of-line' and `end-of-line' key bindings.