TAB KEY working together KEY PRESS event???

TAB KEY working together KEY PRESS event???

Post by thoma » Wed, 01 Oct 2003 23:59:30


I use the Keypress event to verify when the user typing
the ENTER KEY, like below:

if (e.KeyChar == 13){//using the ASCII code of a ENTER KEY
if (this.cboSiglacolecao.SelectedIndex > 0){

this.siglaColecao = "";
this.cboSiglacolecao.DroppedDown = false;
{
}

But now i need to verify when the user typing the ENTER
KEY and the TAB KEY.
The ASCII code of the TAB KEY is (11 - Vertical Tabulator
and 9 - Horizontal Tabulator) but when i use them the code
does not function, like below:

if (e.KeyChar == 13 || e.KeyChar == 9){//using the ASCII
code of a ENTER KEY and TAB KEY
if (this.cboSiglacolecao.SelectedIndex > 0){

this.siglaColecao = "";
this.cboSiglacolecao.DroppedDown = false;
{
}

How can i execute the code when the user pressures the TAB
KEY?
OR
How can i capture the ASCII code of the TAB KEY?
 
 
 

1. (Key press event origin) Is any key phisically pressed?

2. How can I capture tab key event and cancel default action of Tab key?

The default action of tab key is to move focus.
For example,
<textarea id="ta"></textarea>
<textarea id="tb"></textarea>

Pressing Tab key when cursor is in the first textarea results in cursor
in the second textarea.
Is there a cross-browser way to capture the event of pressing Tab key
in a textarea and canceling the focus-moving action?

I tried the following code:

<textarea id="ta"></textarea>
<textarea id="tb"></textarea>
<script>
document.getElementById('ta').onkeypress = function(e){
e = e || window.event;
var code = e.keyCode || e.which;
var c = String.fromCharCode(code);
if(c == '\t'){
alert('TAB pressed'); return false;
} else return true;
}
</script>

And I put cursor in the first textarea and pressed Tab.
IE 7 showed no alertbox and focus moved. not ok.
Firefox 2.0 showed alertbox and focus stayed. ok.
Opera 9 showed alertbox and focus moved. not ok.

3. ActiveX control does not allow arrow key input until tab key press

4. initiate key pressing tab key

5. Key Down Key Press Event Use for Ctrl-d

6. Catching Alt Key Press with the Key Down Filter Event

7. Capturing key press/release events on keyboard for all keys in VC+

8. Press one key = several keys pressed

9. How to Find the Key Being Pressed and then Send a Key Press Programatically

10. CTRL key pressed locks key press detecting

11. catching key press event like alt+tab

12. Trapping the TAB key press event

13. how can I trap the change event (Tab Press key) of these controls

14. catching key press event like kde alt+tab application switcher

15. how can I trap the change event (Tab Press key) of these contr