Take out autofocus on any key press and fix enter bug

This commit is contained in:
Alan Friedman 2016-01-08 17:58:25 -05:00
parent 197dbcdbd8
commit a4326b65e5

View File

@ -216,19 +216,16 @@ $(function() {
// Keyboard events
$window.keydown(function (event) {
// Auto-focus the current input when a key is typed
if (!(event.ctrlKey || event.metaKey || event.altKey)) {
$currentInput.focus();
// When the client hits ENTER on their keyboard and chat message input is focused
if (event.which === 13 && $('.inputMessage').is(':focus')) {
sendMessage();
socket.emit('stop typing');
typing = false;
}
// When the client hits ENTER on their keyboard
if (event.which === 13) {
if (username) {
sendMessage();
socket.emit('stop typing');
typing = false;
} else {
setUsername();
}
// If enter is pressed on key input then close key modal
if (event.which === 13 && $('input#key').is(':focus')) {
$('#key-modal').modal('hide');
}
});