I am trying to make a very simple bash script that emulates the behavior of checkboxes in appearance! I want it to show some parameters and move the cursor to the next checkbox according to pressing the left or right arrow keys. I already managed to do this, using the READ and Ansii escape sequences to detect the arrow keys, and I use tput to move the cursor.
My problem is that I need to read a specific letter (x, for example) that needs to be clicked, and then take another action. But how can I detect this keystroke and at the same time determine if the arrow key is pressed or not?
To detect ansii codes, I need to read 3 characters and with an X character ("select" key) I need to read only one, how can I read 3 characters and at the same time read only one?
I also tried to do something so that the user could just press the left or right arrow keys or the x key, but if he presses any other key, nothing should happen!
I made it this far:
#!/bin/bash
Yes, I know, this is not the most perfect code, but I'm trying to learn. Suggestions will be greatly appreciated.
source share