Reputation: 53
Is there any way I can use the arrow keys instead WASD kays in a choice command in batch without some external program?
Thanks!
Upvotes: 0
Views: 2267
Reputation: 67216
Well, if the solution is restricted by whitout some external program, then the answer is: no way! However, there is a very simple solution using PowerShell, that is installed in any modern Windows computer:
@echo off
setlocal
cls
echo Press a key, ESC to end
:loop
for /F %%k in ('PowerShell Write-Host $Host.UI.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\"^).VirtualKeyCode') do set "key=%%k"
echo Key read: %key%
if %key% neq 27 goto loop
The problem with this solution is that it run slow, although it may be enough for some programs. However, there is a way to speed up this method that is described with detail at this post.
Upvotes: 3