Hi,
If the USB is connected, the Q1 will conduct and the output will ALWAYS be 0.
If the button is not pressed, R3 will charge the capacitor (in about 7ms to Vbase-on) and the Q2 will turn on, again pulling the output low. JMeter Training in Pune
If the button is pushed, the capacitor will be discharged and the Q2 be turned off, if then Q1 is also off (no USB connected) R2 will pull the output weakly high to the supply voltage. That signal is “strong enough” for a microcontroller, but if you need it to be stronger, you can reduce the resistance or build a sort of H-driver with one PNP and one NPN transistor.
The resistors are chosen such that at 5V the system will not drain more than 0.2mA (both USB connected and SW1 pushed in), reducing the resistances will increase the current draw, increasing them will reduce the consumption.
Be aware that changing R3 will also change the time constant for the switch debounce. Higher value -> stronger debounce / slower release response, lower value -> weaker debounce / higher release response. But you can easily vary the capacitor between 0.1uF and 10uF without any danger, larger values will give slower debounce, smaller will give faster response.