Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:01:36+00:00 2026-06-13T09:01:36+00:00

please help how to add variables in this script, does anyone know? Thank you

  • 0

please help how to add variables in this script, does anyone know? Thank you all.

#!/bin/bash

ARROW_UP=???    # I do not know
ARROW_DOWN=???  # I do not know
ARROW_LEFT=???  # I do not know
ARROW_RIGHT=??? # I do not know
ARROW_ENTER=??? # I do not know

case "$KEY" in "$ARROW_UP")    echo "press the up arrow key"
               "$ARROW_DOWN")  echo "press the down arrow key";;
               "$ARROW_LEFT")  echo "press the left arrow key"
               "$ARROW_RIGHT") echo "press the right arrow key"
               "$ARROW_ENTER") echo "press the enter key"
esac
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:01:37+00:00Added an answer on June 13, 2026 at 9:01 am

    Try something like this (you might want to add a case to break out of the loop):

    #!/bin/bash
    
    # Reset terminal to current state when we exit.
    trap "stty $(stty -g)" EXIT
    
    # Disable echo and special characters, set input timeout to 0.2 seconds.
    stty -echo -icanon time 2 || exit $?
    
    # String containing all keypresses.
    KEYS=""
    
    # Set field separator to BEL (should not occur in keypresses)
    IFS=$'\a'
    
    # Input loop.
    while [ 1 ]; do
    
        # Read more input from keyboard when necessary.
        while read -t 0 ; do
            read -s -r -d "" -N 1 -t 0.2 CHAR && KEYS="$KEYS$CHAR" || break
        done
    
        # If no keys to process, wait 0.05 seconds and retry.
        if [ -z "$KEYS" ]; then
            sleep 0.05
            continue
        fi
    
        # Check the first (next) keypress in the buffer.
        case "$KEYS" in
          $'\x1B\x5B\x41'*) # Up
            KEYS="${KEYS##???}"
            echo "Up"
            ;;
          $'\x1B\x5B\x42'*) # Down
            KEYS="${KEYS##???}"
            echo "Down"
            ;;
          $'\x1B\x5B\x44'*) # Left
            KEYS="${KEYS##???}"
            echo "Left"
            ;;
          $'\x1B\x5B\x43'*) # Right
            KEYS="${KEYS##???}"
            echo "Right"
            ;;          
        esac
    done
    

    More details here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Close mysql connection (PHP) Please help me, I not know where add
I know I'm not asking this quite right, either. Please help me better form
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Can we add image together with text in a picker view? Anyone please help!
I want to add background image to uinavigationcontroller. Please help me.
I have problem to add jQuery to some existing code, please help. We have
Please help me somebody to convert unicodestring into string This is how i am
Please help me with this update query. I COMPLETELY understand how redundant this is
please help me arrange these 3 buttons horizontally like this photoshopped image: Please take
please help me. I want know about what types of flags to run an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.