Include a shim to allow .toISOString() in IE<=8
clear_keyboard() needs to load a correct keyboard structure rather than a blank otherwise remapping fails. Also reindented some code for readability