i want to detect arrow keys with arsd.terminal.RealTimeConsoleInput,
how can i do that?
thanks for answers already.
Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
4 days ago How i can detect arrow keys with arsd.terminal? | ||||
---|---|---|---|---|
| ||||
i want to detect arrow keys with arsd.terminal.RealTimeConsoleInput, thanks for answers already. |
4 days ago Re: How i can detect arrow keys with arsd.terminal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoda | On Friday, 11 April 2025 at 13:51:59 UTC, Zoda wrote: > i want to detect arrow keys with arsd.terminal.RealTimeConsoleInput, > how can i do that? > > thanks for answers already. Look at the line 150: https://github.com/adamdruppe/arsd/blob/master/terminal.d There are more examples there, like in line 2540. Matheus. |
4 days ago Re: How i can detect arrow keys with arsd.terminal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to matheus | On Friday, 11 April 2025 at 14:28:17 UTC, matheus wrote:
> On Friday, 11 April 2025 at 13:51:59 UTC, Zoda wrote:
>> i want to detect arrow keys with arsd.terminal.RealTimeConsoleInput,
>> how can i do that?
>>
>> thanks for answers already.
>
> Look at the line 150:
>
> https://github.com/adamdruppe/arsd/blob/master/terminal.d
>
> There are more examples there, like in line 2540.
>
> Matheus.
Thanks for your answer, i'm gonna checkout the file.
|
4 days ago Re: How i can detect arrow keys with arsd.terminal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoda | On Friday, 11 April 2025 at 13:51:59 UTC, Zoda wrote: >i want to detect arrow keys with arsd.terminal.RealTimeConsoleInput, The secret is kinda tucked away but here's the enum that defines these keys as magic characters: https://opendlang.org/library/arsd.terminal.KeyboardEvent.Key.html You can use that in a switch along with other characters in a getch loop:
See other notes at the top of this page: If you also need to check for things like shift+arrows, that may be possible (depends on your terminal) but will require you write a full event loop with the https://opendlang.org/library/arsd.terminal.RealTimeConsoleInput.nextEvent.html Note that if you want to just get a line of text from an editor, that's what Terminal.getline is for, has some features similar to gnu readline. It can be extensively customized as well to add tab complete, syntax highlighting, and more by subclassing LineGetter. You can also run your own event loop and filter the events you forward to the linegetter and custom responding to others for maximum control, but that gets quite involved. |
4 days ago Re: How i can detect arrow keys with arsd.terminal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Friday, 11 April 2025 at 19:59:43 UTC, Adam D. Ruppe wrote: >On Friday, 11 April 2025 at 13:51:59 UTC, Zoda wrote: >[...] The secret is kinda tucked away but here's the enum that defines these keys as magic characters: [...] Thanks for the answer, you really helped much. |