Thanks for your reply! I managed to get my original working with the messy JS (changing the value of a variable and detecting that) but your way is far cleaner. I saw somewhere that I needed action-button in class but I didn't know about shiny-bound-input, I will try that.
Do you happen to have a link to some documentation about things like shiny-bound-input? It seems like this method of using index.html over ui.R isn't very popular and I've been having some struggles trying to get it to work.