qaispak qaispak - 3 months ago 16
Javascript Question

using shift with left click for event without Jquerry

My goal is to press a button and perform an action only when the shift key is also pressed. however, it doesn't even seem to recognize the shift key right now. Currently it works with only the right click but like i said, I want it to work with right click + shift.

button.addEventListener("oncontextmenu", function(e) {
document.addEventListener("keydown", function(e) {
console.log("this string wont show");
if (e.keyCode == 16) {
console.log("this string wont show either");
} else {
console.log(e.keyCode); // again it wont show
rightShiftClick(e); // this will execute perfectly.


The event object tells you if the shift key is pressed and there is no "on" when you are attaching the event.

button.addEventListener("contextmenu", function(e) {