How to use RShift + WASD as arrow keys? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
ibgang
Posts: 3
Joined: 02 Dec 2021, 07:12

How to use RShift + WASD as arrow keys?

Post by ibgang » 02 Dec 2021, 07:23

I'm using AHK 2.0-beta.3, and I'm attempting to combine RShift with WASD to achieve the same function as the arrow keys. Below is a minimum example of my hotkeys:

Code: Select all

SendMode "Input"
#SingleInstance Force

>+w::Up
>+a::Left
>+s::Down
>+d::Right
They mostly behave like the arrow keys, except for using shift + arrow keys to highlight text. For example, without any hotkeys enabled, if I press Shift + left arrow with the cursor in the middle of some text, the cursor would move back one character and highlight the character it passed over. However with the above hotkeys enabled, the cursor would only move, but not highlight.

I've found that I purely use LShift to capitalize whilst typing, so I am willing to sacrifice the RShift's regular function. However, if this could be avoided, that would be better.

Any help in achieving this would be appreciated.
Last edited by gregster on 02 Dec 2021, 22:42, edited 1 time in total.
Reason: Topic moved to "AHK v2 Help".

User avatar
mikeyww
Posts: 26607
Joined: 09 Sep 2014, 18:38

Re: How to use RShift + WASD as arrow keys?

Post by mikeyww » 02 Dec 2021, 09:46

Is that the entire script? I had no trouble with it, and would not expect an issue because Left is not part of any hotkey in this script.

ibgang
Posts: 3
Joined: 02 Dec 2021, 07:12

Re: How to use RShift + WASD as arrow keys?

Post by ibgang » 02 Dec 2021, 20:09

mikeyww wrote:
02 Dec 2021, 09:46
Is that the entire script? I had no trouble with it, and would not expect an issue because Left is not part of any hotkey in this script.
That is a small portion of all my hotkeys, but I have tested with only the hotkeys shown above enabled. I'm still not able to highlight characters by using RShift+LShift+W/A/S/D, whereas L/R/Both shifts+arrow keys can highlight characters.

This is a video highlighting the issue: https://streamable.com/2qhv0w

As this worked for you, do you think this may be an issue with AHK's beta version?

Edit: I tried the exact same script using version 1.1.33.10. Now RShift+W/A/S/D moves the cursor AND highlights, whereas in the beta version it only moved the cursor.

User avatar
mikeyww
Posts: 26607
Joined: 09 Sep 2014, 18:38

Re: How to use RShift + WASD as arrow keys?

Post by mikeyww » 02 Dec 2021, 21:26

I see. No. I misunderstood the question, because your original post does not indicate that you want to use LShift. It says that with the hotkeys enabled, Shift+arrow does not highlight text.

I'm not sure that AHK would support that specific combination of the three keys, but someone else may know a way.

gregster
Posts: 8924
Joined: 30 Sep 2013, 06:48

Re: How to use RShift + WASD as arrow keys?

Post by gregster » 02 Dec 2021, 23:02

ibgang wrote:
02 Dec 2021, 20:09
Edit: I tried the exact same script using version 1.1.33.10. Now RShift+W/A/S/D moves the cursor AND highlights, whereas in the beta version it only moved the cursor.
Afaik, there was a change between versions. A remapping like >+w::Up in v2 will release the RShift, and only send Up, while in v1 the modiifier Shift will not be released and a shifted arrow key will be sent.

eugenesv
Posts: 171
Joined: 21 Dec 2015, 10:11

Re: How to use RShift + WASD as arrow keys?  Topic is solved

Post by eugenesv » 05 Dec 2021, 23:54

ibgang wrote:
02 Dec 2021, 20:09
I'm still not able to highlight characters by using RShift+LShift+W/A/S/D
Maybe because you've not remapped RShift+LShift?
Try this, moves cursor without selection with RShift and moves with selection with RShift+LShift

Code: Select all

#Requires AutoHotKey v2.0-beta.3
>+w::  Send        '{Up}'
>+a::  Send        '{Left}'
>+s::  Send        '{Down}'
>+d::  Send        '{Right}'
<+>+w::Send '{Blind}{Up}'
<+>+a::Send '{Blind}{Left}'
<+>+s::Send '{Blind}{Down}'
<+>+d::Send '{Blind}{Right}'
Blind mode docs
The Blind mode avoids releasing the modifier keys (Alt, Ctrl, Shift, and Win) if they started out in the down position, unless the modifier is excluded. For example, the hotkey +s::Send "{Blind}abc" would send ABC rather than abc because the user is holding down Shift.
P.S.
By the way, you may want to consider using the useless CapsLock as a cursor modifier for this purpose, might be a bit more convenient than having to use two hands

ibgang
Posts: 3
Joined: 02 Dec 2021, 07:12

Re: How to use RShift + WASD as arrow keys?

Post by ibgang » 06 Dec 2021, 06:00

eugenesv wrote:
05 Dec 2021, 23:54
ibgang wrote:
02 Dec 2021, 20:09
I'm still not able to highlight characters by using RShift+LShift+W/A/S/D
Maybe because you've not remapped RShift+LShift?
Try this, moves cursor without selection with RShift and moves with selection with RShift+LShift

Code: Select all

#Requires AutoHotKey v2.0-beta.3
>+w::  Send        '{Up}'
>+a::  Send        '{Left}'
>+s::  Send        '{Down}'
>+d::  Send        '{Right}'
<+>+w::Send '{Blind}{Up}'
<+>+a::Send '{Blind}{Left}'
<+>+s::Send '{Blind}{Down}'
<+>+d::Send '{Blind}{Right}'
Blind mode docs
The Blind mode avoids releasing the modifier keys (Alt, Ctrl, Shift, and Win) if they started out in the down position, unless the modifier is excluded. For example, the hotkey +s::Send "{Blind}abc" would send ABC rather than abc because the user is holding down Shift.
P.S.
By the way, you may want to consider using the useless CapsLock as a cursor modifier for this purpose, might be a bit more convenient than having to use two hands
Thank you so much for the solution and the link the docs, it's working perfectly.

I would use your suggestion to use CapsLock as the modifier, but I'm currently using it as a Backspace which I find more convenient than the actual Backspace key- a leftover habit from my failed attempt to learn Colemak,

Hauke
Posts: 1
Joined: 11 Jan 2023, 09:21

Re: How to use RShift + WASD as arrow keys?

Post by Hauke » 11 Jan 2023, 09:23

perhaps someone could use it (a solution with capslock):

Code: Select all

CapsLock::
KeyWait, CapsLock                      ; wait for Capslock to be released
KeyWait, CapsLock, D T0.2              ; and pressed again within 0.2 seconds
if ErrorLevel
   return
else if (A_PriorKey = "CapsLock")
   SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On"
return
*CapsLock:: return                        ; This forces capslock into a modifying key.

#If, GetKeyState("CapsLock", "P") ; is the key pressed down?
i::Up
+i::+Up
j::Left
+j::+Left
k::Down
+k::+Down
l::Right
+l::+Right
u::Home
o::End
z::Pgup
h::Pgdn
return

Post Reply

Return to “Ask for Help (v2)”