Greetings all, So, after much reading through Julia base, I believe I've figured out how to directly read keyboard inputs from the terminal. First, here is the code:
### function main() raw_mode() println("Just type away and see your characters print, line by line.") println("Press escape to exit.") input = readinput() while input != "\e" println(input) input = readinput() end println("Goodbye!") end raw_mode() = ccall(:jl_tty_set_mode, Int32, (Ptr{Void}, Int32), STDIN.handle, true) == 0 || throw("FATAL: Terminal unable to enter raw mode.") function readinput() input = readavailable(STDIN) chars = map(Char, input) return join(chars) end main() ### Just paste this code in a .jl file and execute it directly using `julia filename.jl` in your favorite text terminal. The function "raw_mode" forces the terminal to read from the keyboard directly without having to buffer after an enter key. The function "readinput" will call "readavailable(STDIN)" to block until a key is pressed. Once a key is pressed, "readavailable(STDIN)" will return the key pressed in Vector{UInt8}. The rest of the function just converts that into a String so it is readable, and it's printed afterwards on screen. This process is looped until the escape key is pressed, indicating that the program must now exit. NOTE: Some terminals are pseudoterminals, and they are switched to raw mode using a different process. So if you can't get this example up and running, just let me know. In short, just run the terminal in raw mode and then call on "readavailable(STDIN)" to receive keyboard inputs. I don't know if this is good practice, but it does the job as expected, at least on Windows 10 x64. This took me too long to figure out, so I thought I should share it as it may be useful to someone else in the future. Regards, Yousef