Fixed a bug with numpages calculation where num results an exact multiple of 13

Change-Id: I47f1a308babee6661532385b0b0f979acf8a5e00
Improve keyboard handling

Change-Id: I4c7f8da4a85160e0eb2906cd443feb8fd609f0f5