I am trying to capture the input from user in a combo box, but I am noticing different behaviors. For example, in my onKeyPress event handler which gets triggered when the user first types into a combo box and looks like this:
[code]_onKeyPress : function(code, ctrl, shift) {
this._lastKeyPress = code;
if((code == 67 || code == Event.KEY_INSERT) && ctrl)
{
this.copyToClipboard();
}
if (code == 85 && ctrl) // Ctrl + U: Update
...............
...............
{[/code]
I get the following when the I type *:
code = 16
ctrl = false
shift = true
If I type 8 i get:
code = 56
ctrl = false
shift = false
I have one more event handler for the onKeyPress event, this one for when they are already inside the combo:
[code]combo.event_id = combo.attachEvent(“onKeyPressed”, function(code, ctrl, shift, ev)
{
var combo = this._getCombo(this._lastSelRowId, index);
if (combo.lookupTimer)
{
window.clearTimeout(combo.lookupTimer);
combo.lookupTimer = null;
}
combo.lookupTimer = window.setTimeout(function()
{
var combo = this._getCombo(rowId, index);
combo.lookupTimer = null;
this._loadCombo(rowId, index, code);
}.bind(this), 500);
[/code]
and when I type * in it I get this:
code = 56
ctrl = undefined
shift = undefined
which is the same thing I get when I type 8:
code = 56
ctrl = undefined
shift = undefined
So, I have three questions here:
- Why do I get different behavior both times?
- Why do I get undefined for ctrl and shift in my second onKeyPress event handler?
- In my second event handler, how can I get the actual character the user typed, as opposed to a keyCode? In other words, if the user typed *, how can I capture that?