The question you should ask is: what voltage do you expect to read on the capelet pin when the switch is not pressed?
If you think about it, you will quickly come to the realization that you don't know! And if you don't, how can the machine know?
You'll need to drive a voltage (0V or 3.3V) on the pin while the switch is not pressed and the other voltage (3.3V or 0V, respectively) when the switch is pressed. This is customarily achieved via pull up or pull down resistors. These are large-ish resistors that connect the pin to the voltage you want to read when the switch is not pressed.for instance:
3v3
|
R 10k
|
--------- Va
|
\ S1
|
GND
When the switch S1 is open (not pressed), the voltage at Va will be 3.3V; when you press the switch and close the circuit, it connects Va to GND and the voltage at Va is therefore 0V.
R1 at 10k is large enough that there will not be excessive current flowing to ground through it when the switch is closed and is small enough that the resistor divider it forms with the input resistance of Va won't drop the voltage very far from 3v3. A wide range of values would work there, e.g.: 1k to 100k.
The above is the pullup configuration. Swap 3v3 and GND in the diagram for the pulldown configuration.
If you wonder why does it work without an external resistor when connecting directly to the digital pins, the answer is that they have a pulldown resistor built in, so there's no need for the external resistor.