asweigart / asweigart/bext

Can't detect arrow keys in CMD/Windows Terminal

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
21
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Hi! :) First of all, thanks for the wonderful app!

I have encountered this issue: when I run a script on Windows in CMD or Windows terminal and getKey any of the arrows, the following happens: any arrow is rendered as "a". However, when I run the same code in my IDE, I get '\xe0K', '\xe0M' and so on.

As far as I can see, the problem is that when you try to get key in the native environment, you get "àK", and not "\xe0K".

Any idea how we can fix that? :)

UPD: I've just tested: the "a" that I get in the console is not real "a". Therefore, my theory about "àK" may be onto something...

UPD2: This seems to be the inherited problem of the **msvcrt** module :(

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the arrow-key behavior through getKey in Windows CMD or Windows Terminal, then inspect the msvcrt handling mentioned in the report. Done means arrow keys are detected distinctly instead of being rendered as "a", while preserving the reported behavior in the IDE.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.