Fixed CAPSLOCK handling and tidied up some more things in keyboard.js