1833777 Members
2032 Online
110063 Solutions
New Discussion

Re: Disable keys?

 
SOLVED
Go to solution
Chua Wen Ching
Regular Advisor

Disable keys?

If i want to disable ctrl + c, i will use:
trap '' 1 2 3 15

Can i use trap to disable enter key, backspace key, spacebar key, F1 key, etc? Is there other solutions than using trap.
wenching
5 REPLIES 5
Chua Wen Ching
Regular Advisor

Re: Disable keys?

I am using HP-UX 10.20. Can anyone show me an example in bourne shell script? Thank you.
wenching
harry d brown jr
Honored Contributor

Re: Disable keys?


You really can never disable a key on a keyboard unless you take a five pound sledge hammer to it.

You CAN though, ignore the key with your application. Most key strokes can be ignored via stty.

man stty


live free or die
harry
Live Free or Die
Chua Wen Ching
Regular Advisor

Re: Disable keys?

You mean i need to specify stty command in my application. What if i set the intr key in my application to "^H" but my .profile intr key is "^c". So when i execute it, which one come first? Thank you.
wenching
Bill Hassell
Honored Contributor
Solution

Re: Disable keys?

What you are asking is a more general question: how to process every keystroke, sort of like vi? The answer is that you can use stty to set the appropriate options and then have a very long shell script to handle each character based on the previous character(s).

NOTE: The trap command does not disable a specific character. Instead, the trap numbers refer to kill signals (use kill -l to see a list) and some of these kill signals are assigned by stty to special characters.


Bill Hassell, sysadmin
Chua Wen Ching
Regular Advisor

Re: Disable keys?

Oh, now i understand already. Anyway thanks for your help.
wenching