regardless, i would suggest wiring the switch between a pin and ground and configure the pin as INPUT_PULLUP (this works for analog pins as well)
if you recognize a button "press", you could use a press to toggle "ledflag" avoiding the need to hold the button down