...

View Full Version : keyCode for crtl+enter



deriv3d
07-05-2002, 07:13 AM
I'm trying to call a function from a specific keyCode entry using "onKeypress".

now, the function i'm calling to, needs to be able to recognize "ctrl+enter". What I have so far is this:


-------------------------------------------------------------------

var reValidChars = /\d/;
var reKeyboardChars = /[\x08\x0D]/;

function ctrl_Enter(objEvent) {
var iKeyCode, strKey;
if (objEvent.keycode == "10") {
if (!reValidChars.test(strKey) && !reKeyboardChars.test(strKey)) {
window.alert('you hit ctrl plus enter!');
}
}
}

------------------------------------------------------------------

Any input will help!! I have been lothing over my computer screen for days now.

glenngv
07-05-2002, 08:40 AM
use onkeydown instead of onkeypress.

var ctrl = event.ctrlKey;
var code = event.keyCode;

alert(ctr);
alert(code);

if (ctrl && code==13)
alert("You press CTRL+Enter");

I'm not sure that the keyCode for Enter is 13 (or 10?), change it appropriately if it was wrong. I did not test it.

deriv3d
07-06-2002, 04:49 PM
Thanks! Much less code, It works great as-is.

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum