mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
18 lines
569 B
TypeScript
18 lines
569 B
TypeScript
export function pressKey(key) {
|
|
document
|
|
.querySelector(".jspsych-display-element")
|
|
.dispatchEvent(new KeyboardEvent("keydown", { key }));
|
|
document
|
|
.querySelector(".jspsych-display-element")
|
|
.dispatchEvent(new KeyboardEvent("keyup", { key }));
|
|
}
|
|
|
|
export function mouseDownMouseUpTarget(target) {
|
|
target.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
|
|
target.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
|
|
}
|
|
|
|
export function clickTarget(target) {
|
|
target.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
}
|