Check if stdin is a terminal (libc::isatty == 1)If not, open /dev/ttyPut the terminal in raw input modeEnable TCSADRAINRead a byteIf \x1b, csi, so read next byteIf next byte is [, start reading control sequenceMatch next byteA => upB => downC => rightD => leftH => homeF => endZ => shift-tab_ =>Match next byte~ =>Match next byte1 => home2 => insert3 => delete4 => end5 => page up6 => page down7 => home8 => endElse, the escape sequence was unknownElse, the escape sequence was unknownElse, if next byte is not [, bail out on unknown control sequenceElse, if there was no next byte, input was Else, if byte & 224u8 == 192u8, Unicode 2-byteElse, if byte & 240u8 == 224u8, Unicode 3-byteElse, if byte & 248u8 == 240u8, Unicode 4-byteElse:If byte == \r || byte == \n, If byte == \t, If byte == \x7f, If byte == \x1b, If byte == \x01, If byte == \x05, If byte == \x08, Else, char = byteElse, if no byte to read:If stdin is a terminal, return NoneDisable TCSADRAIN