Closed jksmithing closed 11 years ago
Looked at this a bit more this morning... seems like detecting key presses in JS is a huge mess.
But I also noticed that fixing another issue fixed this one: https://github.com/twitter/bootstrap/issues/6635. (I just added a logical NOT before the bitwise NOT.)
I think that's pretty minor (no one else seems to have ran into it) - if you've got a fix for it, id' be happy to merge so long as it doesn't break backwards compat
Issue not fixed as claimed; this still happens because move is called inside of keypress. This is a little hacky, and so I'm reluctant to submit this, but this is a sort of fix, inside the move function of bootstrap-typeahead.js:
case 40: // down arrow
if(e.type === 'keypress') break // 40 is open paren inside a keypress
e.preventDefault()
this.next()
break
}
Blech.
In v2.2.2, in the
move
function, there's a switch for the eventkeyCode
. What's problematic is that, at least in Chrome 24, thekeyCode
attribute of akeypress
event is not the same as thekeyCode
attribute of akeydown
orkeyup
event. See: http://msdn.microsoft.com/en-us/magazine/ff928319.aspxThe
keyCode
value inkeypress
events is actually the Unicode code point. For example, if I type a left parenthesis, I get akeyCode
of 40 in thekeypress
event, which also happens to be the JS key code for the down arrow.I haven't tested for other conflicts, but if you have an item in your Typeahead
source
with a left parenthesis (otherwise the menu won't be shown), then you will be prevented from typing a left parenthesis. Fiddle: http://jsfiddle.net/neonsilk/YMqRG/