Well, there is a time ago was looking for a function that uses one button with two functions, and saw the people looking for it. I found a possible solution that worked for me. and I will share here.
Hello, I am Brazilian and sorry for any errors, my English is bad.
The sample code can be downloaded from the gist attached link.