Home > Blockchain >  How to detect TAB key in BASH?
How to detect TAB key in BASH?

Time:11-13

I have this piece of bash code below,

#!/bin/bash

while true; do
read -rsn1 input
if [ "$input" = "a" ]; then
    echo "triggered"
fi
done

It works fine when I press "a" key, however what I really want is trigger something when user press TAB key. How can I make it work? Many thanks for help!

CodePudding user response:

If you do not want the scanning to be split with IFS, then set IFS to empty.

IFS= read -rsn1 input
  • Related