code: func readInputEvents(fd uintptr, maxBytes int) ([]winterm.INPUT_RECORD, error) {
  	// Determine the maximum number of records to retrieve
  	// -- Cast around the type system to obtain the size of a single INPUT_RECORD.
  	//    unsafe.Sizeof requires an expression vs. a type-reference; the casting
  	//    tricks the type system into believing it has such an expression.
  	recordSize := int(unsafe.Sizeof(*((*winterm.INPUT_RECORD)(unsafe.Pointer(&maxBytes)))))
  	countRecords := maxBytes / recordSize
  	if countRecords > ansiterm.MAX_INPUT_EVENTS {
  		countRecords = ansiterm.MAX_INPUT_EVENTS
  	} else if countRecords == 0 {
  		countRecords = 1
  	}
  	logger.Debugf("[windows] readInputEvents: Reading %v records (buffer size %v, record size %v)", countRecords, maxBytes, recordSize)
  
  	// Wait for and read input events
  	events := make([]winterm.INPUT_RECORD, countRecords)
  	nEvents := uint32(0)
  	eventsExist, err := winterm.WaitForSingleObject(fd, winterm.WAIT_INFINITE)
  	if err != nil {
  		return nil, err
  	}
  
  	if eventsExist {
  		err = winterm.ReadConsoleInput(fd, events, &nEvents)
  		if err != nil {
  			return nil, err
  		}
  	}
  
  	// Return a slice restricted to the number of returned records
  	logger.Debugf("[windows] readInputEvents: Read %v events", nEvents)
  	return events[:nEvents], nil
  }
docs: // readInputEvents polls until at least one event is available.