1753259 Members
4941 Online
108792 Solutions
New Discussion юеВ

Backspace handling

 
Mike Keys
Regular Advisor

Backspace handling

Well, thanks to this forum, I'm almost done writing the script I have been working on. Just applying some finishing touches to it.

One thing I need to do is a little input handling. How would I go about coding the input from STDIN to accept a backspace (i.e. if a user types in a wrong letter, they can press backspace to delete the mispelled letter).

Also, in conjunction with this, I need to fix the input cursor and not allow the user to backspace/delete past the first character.
4 REPLIES 4
Mike Keys
Regular Advisor

Re: Backspace handling

O.K. how about this. The delete key works as I want it to. Can I disable to function of the backspace key when running a perl script?
Mike Keys
Regular Advisor

Re: Backspace handling

Problem was with terminal definition.
RAC_1
Honored Contributor

Re: Backspace handling

Try following.

tput 25,25
echo "Key in the CHOICE"
stty erase "the_back_space"
# (You do that with stty erase ^backspace key)

read answer

your stuff goes here.

This should work without problems.
There is no substitute to HARDWORK
generic_1
Respected Contributor

Re: Backspace handling

stty erase (hit spacebar once) (hit returnkey)
It works.

Also, Ctrl+hkey works to backspace.


** Please assign points to all the nice folks who have been answering your questoins with the blue button at the bottom left of submit. They would apprciate it. Thanks.