code: def getch_selection(colors, per_page=15):
      
      global transparency, prefix, current
      get_transparency()
      
      page = 1
      length = len(colors)
      last_page = length / per_page
  
      if (last_page * per_page) < length:
          last_page += 1
  
      getch = _Getch()
  
      valid = False
      while valid == False:
          menu_pages(colors, page, True, per_page)
          sys.stdout.write(">")
          char = getch()
  
          try:
              int(char)
              entry = raw_input_with_default(' Selection: ', char)
              entry = int(entry)
              if colors[entry - 1]:
                  valid = True
  
          except ValueError:
              pass
  
          if( char == 'j' ):
              page += 1
              if page > last_page:
                  page = last_page
              menu_pages(colors, page, True, per_page)
  
  
          if( char == 'k' ):
              if(page > 1):
                  page -= 1
              else:
                  page = 1
              menu_pages(colors, page, True, per_page)
  
  
          if( char.lower() == 'q' ):
              c = os.system('clear')
              sys.exit(0)
  
          if( char == 'J' ):
              if transparency > 0:
                  transparency -= 1
              menu_pages(colors, page, True, per_page)
  
          if( char == 'K' ):
              if transparency < 100:
                  transparency += 1
              menu_pages(colors, page, True, per_page)
  
          if( char.lower() == 'p' ):
              prefix = raw_input_with_default(' prefix: ', 'urxvt')
              
          if( char == '\r' ):
              return current
  
      return colors[entry - 1]
docs: prompt for selection, validate input, return selection