Skip to content

Commit

Permalink
bypass arrow keys; use bypass to improve cursor handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mahiuchun committed Apr 3, 2015
1 parent 3f24355 commit 9efba4f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ $('#edit').keydown(function(event) {
return true;
} else if (219 <= event.keyCode && event.keyCode <= 222) { // punctuations
return true;
} else if (37 <= event.keyCode && event.keyCode <= 40) { // arrow keys
return true;
} else if (enmode) {
return true;
} else if (65 <= event.keyCode && event.keyCode <= 90) { // A-Z
Expand All @@ -57,9 +59,7 @@ $('#edit').keydown(function(event) {
candidates = [];
offset = 0;
show_candidates();
var edit = $('#edit').val();
edit = edit.substring(0, edit.length - 1);
$('#edit').val(edit);
return true;
}
} else if (0x30 <= event.keyCode && event.keyCode <= 0x39) { // 0-9
var select = event.keyCode - 0x30 - 1;
Expand All @@ -68,7 +68,7 @@ $('#edit').keydown(function(event) {
}
var edit = $('#edit').val();
if (candidates.length === 0) {
$('#edit').val(edit + (event.keyCode-0x30).toString());
return true;
} else if (offset + select < candidates.length) {
$('#edit').val(edit + candidates[offset+select]);
preedit = '';
Expand All @@ -85,8 +85,7 @@ $('#edit').keydown(function(event) {
}
show_candidates();
} else {
var edit = $('#edit').val();
$('#edit').val(edit + ' ');
return true;
}
} else {
console.log(event.keyCode);
Expand Down

0 comments on commit 9efba4f

Please sign in to comment.