Controlling 2 LED's and sensing a button press all using a single pin
The 2 LEDs are driven 'as usual' (driving the PIC i/o pin Lo illuminates Red 20mA, driving Hi illuminates Green 10mA)
When no LED is lit (PIC i/o = input), the internal 'weak pull up' (or R3) of 22k will hold the pin Hi (there should be insufficient current to light G LED, but even is so, Green LED Vf will hold the pin to 3v min (and a '1' will be seen so long as the pin is 2v or above)
When the user presses the button, this will pull the PIC pin to 0v6 max. and a '0' will be seen. It will also pass approx 10mA through the Red LED (so approx 50% lit)
The danger is that the user may press the LED when the PIC is driving Hi (Green LED lit) - if this happens, the i/o pin will have to source 20mA via R4 + 10mA via G LED & R2 = 30mA total which is outside the PIC spec. (25mA) and risks burning the pin. So, to 'protect' against this, the PIC s/w code has to check for the button (switch the i/o pin between Green Hi drive and input sense) at regular intervals = the human eye won't spot anything over 30Hz.
Note, if 'feedback' is required (so the user knows their button press has been 'seen'), the PIC should respond by pulling the i/o pin Lo (so Red LED now 100%) and not Hi (Green) (unless 'strobing' is used to stay within the 25mA current limit)