# Obtain a Y or N response

```ruby
func prompt_yn {
    static rk = frequire('Term::ReadKey')
    rk.ReadMode(4)     # change to raw input mode
 
    var key = ''
    while (key !~ /[yn]/i) {
        while (rk.ReadKey(-1) != nil) {}   # discard any previous input
        print "Type Y/N: "
        say (key = rk.ReadKey(0))          # read a single character
    }
 
    rk.ReadMode(0)     # reset the terminal to normal mode
    return key.uc
}
 
var key = prompt_yn()
say "You typed: #{key}"
```

#### Output:

```
Type Y/N: a
Type Y/N: b
Type Y/N: c
Type Y/N: y
You typed: Y
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/k/keyboard-input/obtain_a_y_or_n_response.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
