That's what `modifyOtherKeys` mode is for, introduced by xterm a couple decades ago. It tells the terminal to report modified keys with a control sequence that explicitly specifies the base key and modifiers.
Use something with a sane key event handling system. List here: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
(My particular use that drove me down this rabbit hole was using "Shift" for selection. You CANNOT DO THIS with "standard" terminals as you cannot detect when shift gets pressed or released without also pressing another key.)
I'll wait ...
(It's this kind of basic stuff that doesn't work that makes me absolutely laugh my ass off when people claim that "AI will take all the programming jobs".)