As you have the luxury of 5 I/O pins here's a suggestion based upon the 4017 (one out of 10) Johnson ring counter. The full circuit would use three 4017 ICs with the CLOCK and RESET lines in common and separate DATA lines for each chip (data1,data2,data3) which would be read in parallel.
This allows for all 30 switches to be read in 10 read cycles and also allows for multiple switch operations. The diodes used are general purpose types such as a 1N4148. Their function is to prevent a LOW output from being connected to a HIGH output and shorting it out (pulling it LOW). R1 is a pull down resistor. The value is not critical so anything between a few hundred ohms and a few 10Ks would be fine. Only ONE output is HIGH at any time and this output is the only one that can produce a HIGH on the data line (input to controller) IF the switch is closed.
Basic circuit. (1 out of 10)
This shows the set up for a single 10 switch read. The data (input) line will be held LOW by R1 (value not critical). To scan the switches the counter is first reset so output 0 goes HIGH. If switch '0' is pressed then it will place a voltage across R1 and the data line goes HIGH if the switch is not pressed the data line will be LOW. This can be read by the controller. The controller then produces a clock pulse and output 1 goes HIGH. If switch 1 is closed the data line will be HIGH. If the switch is open the data line will be LOW and so on. By clocking through all the outputs each switch can be tested making it possible to 'see' multiple key presses by storing each value in turn.
Meta Code.
Clockcount == 0; // a counter to identify which 4017 output (bit position)
lastpress == thispress ; // remember last keypress pattern (16 bit) - useful for monitoring changes and debouncing etc.
thispress == 0; set up new keypress variable (bit pattern of switches)
Toggle(Resetpin); // reset 4017 for '0' output HIGH
inputupdate(datapin); // get the value of the data line (HIGH = keypress, LOW = no keypress)
// and store new value in thispress (16 bit switch image)
Loop until Clockcount = 10 ; {
Clockcount++ // increment clock counter (1,2,3,4,5,6,7,8,9)
Toggle(clockpin); // increment 4017 counter for next output
inputupdate(datapin); // get the value of the data line (HIGH = keypress, LOW = no keypress)
// and store new value in thispress
}