Similar to the Konami Code in old videogames, the function would record, for a moment, what the player did, and "watch" for a specific combination.
CodePudding user response:
From what I read, Konami Code just hooked keystrokes and monitored the stream of keystrokes looking for a specific sequence in order to activate a "cheat code".
That's a different problem than prompting for input from stdin
, disabling echo and/or masking the input as it's type and reading it.
If the latter is what you want to do, as in prompting for a password, you might take a look at the package x/term
and its term.ReadPassword()
function, which
reads a line of input from a terminal without local echo. This is commonly used for inputting passwords and other sensitive data. The slice returned does not include the
\n
.
CodePudding user response:
This works:
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
fmt.Println(n == 9)
}
If I enter 9
, the program will print true
.