Combining keycode events in jQuery?

Checking e. KeyCode == 16 && e. KeyCode == 188 won't do anything useful because e.

KeyCode won't be both 16 and 188 at the same time. The && operator is a logical conjunction so it evaluates to true if the expressions on both sides of it are true I think you want to look at e. ShiftKey if that's true then the Shift key is down, if e.

ShiftKey is false then Shift is not down: if(e. ShiftKey && e. KeyCode == 191) { //?

} else if(!e. ShiftKey && e. KeyCode == 191) { // / }.

Checking e. KeyCode == 16 && e. KeyCode == 188 won't do anything useful because e.

KeyCode won't be both 16 and 188 at the same time. The && operator is a logical conjunction so it evaluates to true if the expressions on both sides of it are true. I think you want to look at e.

ShiftKey; if that's true then the Shift key is down, if e. ShiftKey is false then Shift is not down: if(e. ShiftKey && e.

KeyCode == 191) { //? } else if(!e. ShiftKey && e.

KeyCode == 191) { // / }.

Using e. ShiftKey has the problem of appending both the non shiftkey character and shiftkey character. Example: e.

ShiftKey && e. KeyCode == 188 returns / and?. – pardon Nov 1 at 3:11 @pardon: Not sure what you mean: jsfiddle.Net/ambiguous/dJVWw – mu is too short Nov 1 at 3:17 for every e.

ShiftKey && e. KeyCode == 191, there's also a simple e. KeyCode == 191.

So the shiftkey event appends both the shifted character (?) and the unshifted character (/). – pardon Nov 1 at 3:24 @pardon: I don't follow you. That jsfiddle.

Net only shows question marks for me, no slashes. – mu is too short Nov 1 at 3:37 that's because it only has half the functionality i'm looking for. Here's what was giving me both characters: jsfiddle.

Net/pardon/GUwmz/1 and here's how I solved it: jsfiddle. Net/pardon/8HHKN – pardon Nov 1 at 4:03.

Because each key creates its own keydown event, it will never be possible for keyCode to equal both 16 and 188. Luckily the SHIFT state is stored in event. ShiftKey :).

Shiftkey appends both the "shifted" character and the non-shifted character :( – pardon Nov 1 at 3:15.

Try this $(document). Keydown(function(e) { if (e. ShiftKey){ if (e.

Which == 188) { alert('both'); } } }).

That got close. I just solved it! $(document).

Keydown(function(e) { if (e. KeyCode == 191) { if (e. KeyCode == 191 && e.

ShiftKey){ $('#myDiv'). Append('? '); } else { $('#myDiv').

Append('/'); } } }); – pardon Nov 1 at 3:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions