after you develop reliable code to recognize a button press and a button un-press, add code to measure the time between them and then add code to do something base on the duration of the press
gcjr:
after you develop reliable code to recognize a button press and a button un-press, add code to measure the time between them and then add code to do something base on the duration of the press
Another hint: if your button is wired to GND then a button press with be a HIGH to LOW transition and a button release will be a LOW to HIGH transition. Measure the time between those transitions.
As gcjr said, get simple code working that recognizes a button press, then add code to recognize a button release, then add code to time in between...incremental development we call it.
Getting a single button to do multiple things can be very confusing for users - how does the user know when s/he has held the button long enough, but not too long?