How to scan and differentiate multiple switches through a single input/output pin?
The principle in this technique is not so exact and reliable. 

In this technique the mcu estimate how large is the discharging time. 
A timer is clocked, capacitor began to discharge, comparator is in the match voltage interrupt. That means when the voltage of input pin is equal or bigger than a specific voltage(that is defined in program, e.g. internal 2.56V) an interrupt will arise. Now in interrupt routine you can measure timer/counter value.

It's time is proportional to RC value that for equal C it means proportional to R. we can estimate the value of resistance. then you can guess which key is down.

A better and more reliable way is to use an ADC pin to attach multiple Buttons. A good explanation is formed here : http://www.edn.com/design/analog/4439796/Read-multiple-switches-using-ADC

Basic Rule of this technique is described in below picture :

 

Different switches, will produce different voltage on pins. 

Main Advantage of this technique is that your buttons can pushed together simultaneously so the overall voltage is the equivalent voltage of overall resistance. You should select good resistor values to have different voltages for different switches pushed.

And at last another easy way to connect multiple switches is to use a decoder IC like 74148. for example connecting 16 button to 4 pins.