Check for null and bind keydown

Kind of embarrassing... when I remade my pull request, I forgot to check
for null errors if the client used tab excessively. Also, it didn't
include the $document.bind line.. kind of strange.
Merge pull request #1153 from pkt77/fix

Check for null and bind keydown