code: def _GetRawKeyFunctionPosix():
      """_GetRawKeyFunction helper using Posix APIs."""
      # pylint: disable=g-import-not-at-top
      import tty
  
      # pylint: disable=g-import-not-at-top
      import termios
  
      def _GetRawKeyPosix():
          """Reads and returns one keypress from stdin, no echo, using Posix APIs.
  
          Returns:
            The key name, None for EOF, <*> for function keys, otherwise a
            character.
          """
          ansi_to_key = {
              "A": "<UP-ARROW>",
              "B": "<DOWN-ARROW>",
              "D": "<LEFT-ARROW>",
              "C": "<RIGHT-ARROW>",
              "5": "<PAGE-UP>",
              "6": "<PAGE-DOWN>",
              "H": "<HOME>",
              "F": "<END>",
              "M": "<DOWN-ARROW>",
              "S": "<PAGE-UP>",
              "T": "<PAGE-DOWN>",
          }
  
          # Flush pending output. sys.stdin.read() would do this, but it's explicitly
          # bypassed in _GetKeyChar().
          sys.stdout.flush()
  
          fd = sys.stdin.fileno()
  
          def _GetKeyChar():
              return encoding.Decode(os.read(fd, 1))
  
          old_settings = termios.tcgetattr(fd)
          try:
              tty.setraw(fd)
              c = _GetKeyChar()
              if c == _ANSI_CSI:
                  c = _GetKeyChar()
                  while True:
                      if c == _ANSI_CSI:
                          return c
                      if c.isalpha():
                          break
                      prev_c = c
                      c = _GetKeyChar()
                      if c == "~":
                          c = prev_c
                          break
                  return ansi_to_key.get(c, "")
          except:  # pylint:disable=bare-except
              c = None
          finally:
              termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
          return None if c in (_CONTROL_D, _CONTROL_Z) else c
  
      return _GetRawKeyPosix
  
file_path: python-fire/fire/console/console_attr_os.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import unicode_literals
  import os
  import sys
  from fire.console import encoding
label_desc: Use image node_id 7 for calling a global function with example usage: _GetRawKeyFunctionPosix() and returns: _GetRawKeyPosix, unknown, encoding, ansi_to_key, c