Forum Discussion
Center Click Trigger
Nathanial,
I got it with a javascript function that triggers when the objected is either selected or hovered over.
// Get the player object
var player = GetPlayer();
function simulateF9KeyPress() {
// Create a new KeyboardEvent
let event = new KeyboardEvent('keydown', {
key: 'F9',
code: 'F9',
keyCode: 120, // F9 key code
which: 120, // F9 key code
bubbles: true,
cancelable: true
});
// Dispatch the event on the document
document.dispatchEvent(event);
}
// Add event listener for middle mouse button click
document.addEventListener('mousedown', function(event) {
// Check if the middle mouse button (button code 1) was clicked
if (event.button === 1) {
simulateF9KeyPress();
}
});
// Optional: Prevent the default action of the middle mouse button click
document.addEventListener('click', function(event) {
if (event.button === 1) {
event.preventDefault();
}
});
Thanks