←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft


Help with key binding

L1veAgainTeam's Photo L1veAgainTeam 01 Mar 2015

Ok so i have an OS i've been working on for 2 years and felt like it'd be an amazing feature to add something like CTRL+R to refresh the desktop, now here's my problem, i can't find the code where computercraft binds CTRL+T to terminate a process in which i was going to use to help me do what i planned and was wondering if anyone else could help me to figure it out, any help is appreciated :)

Lyqyd's Photo Lyqyd 01 Mar 2015

The Ctrl-R, Ctrl-S, and Ctrl-T key combinations are all detected on the Java side of things, so you won't be able to change their behavior, with the limited exception of ignoring the terminate events that Ctrl-T creates.

Bomb Bloke's Photo Bomb Bloke 02 Mar 2015

You can detect other Ctrl + key combos, though: If you're holding Ctrl, then pressing a character key will generate a key event, but won't generate the corresponding char event like it usually would.

Thus if you queue a custom event after pulling a key event, you can determine whether Ctrl was being held down at the same time based on whether a char event comes out of the queue before your custom event does.

L1veAgainTeam's Photo L1veAgainTeam 03 Mar 2015

Ah okay then, i'll try what Bomb Bloke said and if that doesn't go too well i'll try other things, thanks anyways :)