danielfarrell / bootstrap-combobox

A combobox plugin that works with twitter bootstrap
849 stars 328 forks source link

Bug in typing ampersand #253

Open FishnetNewMedia opened 6 years ago

FishnetNewMedia commented 6 years ago

When typing an ampersand while results are currently displayed (this.shown == true) results in the ampersand not appearing. The reason is that the keypress event handler runs the move() method, and the move() method prevents the default behavior for keycode 38. There is a difference between keycodes triggered by the keydown and keypress events. keydown keycodes are codes that represent the key(s) pressed. For example, pressing SHIFT+7 will result in two keydown events with keycodes 16 ("SHIFT" key) and 55 ("7" key), however, the keypress returns a character represented by the result of pressing the combined keys. This produces a keycode 38 (ampersand). But keycode 38 is also the keycode result from pressing the up arrow key when passed to the keydown event. Since the events are somewhat redundant, my recommendation is to eliminate this.move() from the keypress event.