Fix sending wrong keys when using multiple keyboard layouts

I think this patch fixed following bugs.
https://code.google.com/p/semicomplete/issues/detail?id=13
https://code.google.com/p/semicomplete/issues/detail?id=21
https://code.google.com/p/semicomplete/issues/detail?id=41#c1
https://code.google.com/p/semicomplete/issues/detail?id=76
Fix outputting a small letter when a capital letter is intended and the key is bound

I think this patch fixed following bugs.
https://code.google.com/p/semicomplete/issues/detail?id=57
https://code.google.com/p/semicomplete/issues/detail?id=65