View Full Version : keyCode for crtl+enter

07-05-2002, 08: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.

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

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


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.

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