joytyper() {
  declare -a table=($(awk 'NR>1{print $3}' /home/pi/ADMIN/.sys/.char_table)); #for c in "${table[@]}"; do echo "$c"; done
  declare -a columns=(); declare -a input_bytes=()
  local index=0; local count=0; local MK="$(echo -e "\e[0m")"; local UM="$(echo -e "\e[7m")"
  local output_path='/home/pi/ADMIN/.sys/.joyString'
  local str=''

  if [[ $# -gt 0 ]]; then
    input_bytes=($(echo -n "$@" | hexdump -v -e '/1 "%02X\n"'))
    for b in "${input_bytes[@]}"; do i=$(echo "${table[@]}" | awk -v val="$b" '{for(i=1;i<=NF;i++) if ($i ~ val) print (i-1)}'); [[ $i =~ ^[0-9]+$ ]] && columns+=("$i"); done
  fi

  columns+=("0")

  [[ ${#columns[@]} -gt 0 ]] && index=$((${#columns[@]}-1)); count=${columns[$index]}

  clear; read -rs -t 1 void >/dev/null

  for c in "${columns[@]}"; do printf "\x${table[$c]}"; done
  tput cup 0 $index; tput sc
  echo -n -e "\e[7m$(printf "\x${table[${columns[$index]}]}")\e[0m"; tput rc

  while :; do
    read -rsn1 k; read -rsn3 -t 0.1 ctl

    case "${k^^}" in
        'U'|'D'|'L'|'R')
            tput rc; echo -n -e "$(printf "\x${table[${columns[$index]}]}")"; tput rc

            case "${k^^}" in
	        'U')
		    (( count++ )); count=$(( count % ${#table[@]} ));
	            columns[$index]="$count";
	            ;;

	      	'D')
		    (( count-- )); [[ $count -lt 0 ]] && count=$((${#table[@]}-1));
		    columns[$index]="$count"
	 	    ;;

	      	'L')
		    (( index-- )); [[ $index -lt 0 ]] && index=0;
	            [ -z "${columns[$index]}" ] && columns[$index]=0;
	            count=${columns[$index]}; tput cup 0 $index; tput sc
	            ;;

	      	'R')
		    (( index++ )); [ -z "${columns[$index]}" ] && columns[$index]=0;
	            count=${columns[$index]}; tput cup 0 $index; tput sc
	            ;;
		esac
                echo -n -e "\e[7m$(printf "\x${table[${columns[$index]}]}")\e[0m"; tput rc
		;;
	*)
	    case $k$ctl in
                $'\E')
		    { for c in "${columns[@]}"; do printf "\x${table[$c]}"; done | sed 's/[[:blank:]]*$//'; printf "\n"; } > $output_path
                    clear; sleep 1
		    echo -e "'$(cat $output_path)' [$(($(cat $output_path | wc -c)-1))]\t$output_path"
		    return
                ;;
            esac
        ;;
    esac
  done
}
