

How to detect Click + [Shift, Ctrl, Alt] in the click event of reacjs?
source link: https://www.codesd.com/item/how-to-detect-click-shift-ctrl-alt-in-the-click-event-of-reacjs.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to detect Click + [Shift, Ctrl, Alt] in the click event of reacjs?
I want to do some other things when user Click+[Ctrl], but it seems that I could not detect if user press Ctrl when clicking.
I copy the event object infos below.
bubbles : false
cancelBubble : false
cancelable : false
currentTarget : react
defaultPrevented : false
eventPhase : 2
isTrusted : false
path : Array[1]
returnValue : true
srcElement : react
target : react
timeStamp : 5690056.695
type : "react-click"
I can see the ctrlKey attribute in the arguments[0]-Proxy Object. But this object is unaccessable('Uncaught illegal access'):
[[Target]]
:
SyntheticMouseEvent
_dispatchInstances:ReactDOMComponent
_dispatchListeners:(e)
_targetInst:ReactDOMComponent
altKey:false
bubbles:true
button:0
buttons:0
cancelable:true
clientX:275
clientY:315
ctrlKey:false
Your click handling function would have a format as such:
clickHandler: function (event, value) {
event.stopPropagation();
// In that case, event.ctrlKey does the trick.
if (event.ctrlKey) {
console.debug("Ctrl+click has just happened!");
}
}
Recommend
-
17
Adding SHIFT / CTRL Click support to links in Flash Monday, May 5, 2003 One of the requests that I got for the Google search applicati...
-
7
One simple trick to make Event Sourcing clickHi, weʼre arkency 👋 Event Sourcing is like having two methods when previously there was one. There — I’ve said it. But it isn’t...
-
6
221036 – [Win] focus event is not dispatched for form controls when they are focused via mouse click WebKit Bugzilla Bug 221036: [Win] focus event is not dispatched for form controls...
-
14
V2EX › 程序员 vscode 中 ctrl+shift+d 无法切换到调试? uni · 7 小时 35 分钟前 · 173 次...
-
5
V2EX › Windows 升级 win11 后, ctrl+shift+esc 呼不出任务管理器了? mikicomo ·...
-
8
How to detect click inside iframe using JavaScript 35739 views 1 year ago Javascript ...
-
7
The button does not respond to Click Event after Translation advertisements I have performed a Translation anim...
-
4
For database programs, we need to close the database if users press Ctrl+C to terminate the program. This post shows how to capture Ctrl+C event and run the handler in
-
8
[Last Week in .NET #91] – Ctrl+Shift+B Build happened, virtually. Again. I did not Livetweet it this year due to reasons like “self care” and “omg how can anyone do a 3 day virtual conference”, but luck...
-
9
How to Detect a Click Outside of an Element with jQuery 1384 views 2 years ago jQuery Use the event.t...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK