Permalink
Browse files

Minor tweaks related to IME code

- Add comment to explain reason for code
- Change variable name to be more clear about its purpose
- Change to triple equals
  • Loading branch information...
1 parent 38be96c commit bc729899443a612a188c9e87e8be63e1d14359a7 @akavlie akavlie committed Mar 4, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 assets/js/views/chat.js
View
@@ -42,7 +42,9 @@ var ChatView = Backbone.View.extend({
$('#chat-input').val('');
});
- var isEnter = false;
+ // Only submit message on enter if both keydown & keyup are present
+ // so IMEs work
+ var keydownEnter = false;
$('#chat-input').bind({
// Enable button if there's any input
change: function() {
@@ -58,13 +60,13 @@ var ChatView = Backbone.View.extend({
if (event.keyCode == 9) {
event.preventDefault();
}
- isEnter = (event.keyCode == 13);
+ keydownEnter = (event.keyCode === 13);
},
keyup: function(event) {
var self = this;
if ($(this).val().length) {
- if (isEnter && event.keyCode == 13) {
+ if (keydownEnter && event.keyCode === 13) {
var message = $(this).val();
// Handle IRC commands
if (message.substr(0, 1) === '/') {

0 comments on commit bc72989

Please sign in to comment.