Chess is the best game ever invented blah blah blah
Almost everything that's possible with terminal escape codes is on this manual page, so do check it out: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
All you really need to do is send "\x1b[?1000h\x1b[?1006h" to the terminal to enable mouse mode and then the terminal will send something along the lines of this to sys.stdin: "\x1b<0;x;y;m", where x & y are numbers as a string that represent the x and y positions of the click. You can use a regex or the parse module: https://pypi.org/project/parse/. Cheers!
@ash15khng You can "send the string" via writing to
sys.stdout or using a helper function like
The man page I linked is a lot more technical so maybe check out this wikipedia page first: https://en.wikipedia.org/wiki/ANSI_escape_code.
There's some pretty cool shit you can do (background/foreground colors, bold/italic/underline, hyperlinks, clearing the screen or the line, moving the cursor around, getting mouse events [move, click, drag], processing special user keys [like home, end, backspace, ctrl-a, alt-a, etc.]). Also note that windows is quite funky and doesn't use some of these advanced features like linux does (current windows 10 does tho for the most part). If you've ever used a linux terminal gui program like htop, nano, emacs, or vim, they use this same stuff.