OnShape F2 to rename

Remap SHIFT+N to F2

// ==UserScript==
// @name         OnShape F2 to rename
// @namespace    V@no
// @version      2025-01-02
// @description  Remap SHIFT+N to F2
// @author       V@no
// @match        https://cad.onshape.com/documents/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=onshape.com
// @license      MIT
// @grant        none
// ==/UserScript==

{
    'use strict';
/*
^ = CTRL
! = ALT
+ = SHIFT
*/
const map = {
	"F2": {key: "N", code: "KeyN", keyCode: 78, shiftKey: true}
};

let mouseEvt = {};
document.addEventListener('mousemove', evt =>
{
	mouseEvt = evt;
}, false);

document.body.addEventListener("keydown", evt =>
{
	let modifier = "";
	modifier = evt.altKey ? "!" : "";
	modifier = evt.shiftKey ? "+" : "";
	modifier = evt.ctrlKey || evt.metaKey ? "^" : "";
	const key = modifier + evt.code;
	if (!evt.isTrusted || !(key in map) || evt.altKey || evt.shiftKey || evt.ctrlKey || evt.metaKey)
		return console.log(evt, mouseEvt);

	if (mouseEvt.target)
	{
		evt.target.dispatchEvent(new KeyboardEvent(evt.type, Object.assign({}, evt, {key: " ", code: "space", keyCode: 32}, {bubbles: true})));
		mouseEvt.target.dispatchEvent(new PointerEvent("click", mouseEvt));
	}

	evt.target.dispatchEvent(new KeyboardEvent(evt.type, Object.assign({}, evt, map[key], {bubbles: true})));
}, true);
}