Key combination. lazarus / 61-Beginners ---------------------------------------------------------------------- Giorgos · 2020-07-26 18:10 Hi!  I wrote a small program at my Linux system (latest FPC version). Since it uses Crt, ^C is disabled. (A known problem). OK! The program is short, but I think it will be a problem, when it grows...eventually. Is there any way to interrupt a program when ^C is disabled (without sending a sigkill or something)? On a more general approach, is there any way to tell the program, when a certain key combination is pressed to do something specific (exit, or play a sound, or flash a message, or something). I know how to do in other languages, but I'm new to FPC!  Here's the code for a small calculator for exponentiation. I don't think that is buggy. I think it's the Crt thing limitation (bug)? TIA for any help!!!  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Program Exponentiation; uses Crt, Math; var    X, Y, Z: Double;    Esc: Char;                    begin         Repeat                    Writeln;      TextColor(LightMagenta);        Writeln ('Exponantiation');        Writeln;        Writeln ('Base ; ');        TextColor(LightCyan);      Readln (X);        Writeln;        TextColor(LightMagenta);        Writeln ('Exponent ; ');        TextColor(LightCyan);        Readln (Y);        Z:= Power(X, Y);        Writeln;        TextColor(LightMagenta);        Write ('Sum=');        TextColor(LightCyan);        Writeln (Z);        Writeln;        TextColor(LightGray);        Writeln ('Press any key.');        TextColor(LightMagenta);        Write ('Esc ');        TextColor(LightGray);        Writeln ('for Exit.');        Esc:= readKey;        Until Esc=#27;    end. ---------------------------------------------------------------------- Warfley · 2020-07-27 13:53 The easierst solution to your Problem is to not use the CRT Unit I did something like this a while ago, this funczion might be of interest die you: https://github.com/Warfley/LazTextForms/blob/ca92436 2d3b43f5091ceb4d9649a794f2b9e20ae/tfcanvas.pas#L148 And https://github.com/Warfley/LazTextForms/blob/ca924362d3b43f5091ceb 4d9649a794f2b9e20ae/tfcontrols.pas#L301 ---------------------------------------------------------------------- Giorgos · 2020-07-27 22:12 Quote from: Warfley on July 27, 2020, 03:53:45 pmThe easierst solution to your Problem is to not use the CRT Unit THANKS Warfley!    Indeed for more complex programs, one has to avoid Crt. It's a pity though, because you have to manually colorize the output (probably with ncurses), and that means more manual work. Quote from: Warfley on July 27, 2020, 03:53:45 pmI did something like this a while ago, this funczion might be of interest die you: https:// github.com/Warfley/LazTextForms/blob/ca924362d3b43f5091ceb4d9649a794f2 b9e20ae/tfcanvas.pas#L148 And https://github.com/Warfley/LazTextForms/blob/ca924362d3b43f5091ceb 4d9649a794f2b9e20ae/tfcontrols.pas#L301 I'll look at them! ---------------------------------------------------------------------- jamie · 2020-07-27 23:31 If the CRT unit is properly implemented then using a special key on the board should report #0 when doing ReadKey function call and if you do receive a #0 then you jump to a function there it will handle the next readKey which will be any one of the special keys on the board..  Special keys are like F1..F12 etc..  So while in the loop you can use the  KeyPressed to see if a key is pressed and then use the ReadKey to get its value...   and like I said, if there is a special key being held down the Readkey will return #0 and then you perform another Readkey after that which will be the special key code  If you receive this sequence that may indicate an F1 for example you could use the HALT to kill the program ---------------------------------------------------------------------- Warfley · 2020-07-27 23:59 Quote from: Giorgos on July 28, 2020, 12:12:30 amIt's a pity though, because you have to manually colorize the output (probably with ncurses), and that means more manual work. Maybe I have something for you, because since the Windows Console now allows for escape sequences, I've wanted to rewrite my tfcanvas unit (which I linked you above) to not rely on crt for windows anymore (it currently is a mix of using crt on windows and escape sequences for unix). I currently only implemented the coloring mechanisms, but if thats all you want, you can use it For reading keys, look at the ReadSequence function of my TFCanvas unit above, it has code for windows and unix to read sequences like ctrl+key and stuff. Edit: accedentally posted an old (broken) version, just changed the code to the working version, see attachment