send Keycode SHIFT+ARROW

Post your questions and help other users.

Moderator: Martin

anuraag
Posts: 281
Joined: 24 Jan 2015 02:06

send Keycode SHIFT+ARROW

Post by anuraag » 31 Dec 2018 08:11

Is it possible to select some texts like in windows by pressing shift+arrow keys?

I have tried control ui. But its only moving directional pad instead of selecting text.
sendKey("DPAD_LEFT", "SHIFT_ON")

User avatar
Desmanto
Posts: 2194
Joined: 21 Jul 2017 17:50

Re: send Keycode SHIFT+ARROW

Post by Desmanto » 31 Dec 2018 14:42

I also face the same problem, can't use Shift + DPad, or any other combination, example Ctrl+C, Ctrl+V. But using bluetooth keyboard, it is working fine.

Try

Code: Select all

sendKey("DPAD_LEFT","SHIFT_ON")
The cursor only move to the left, not selecting the char. Log from KeyEvent

Code: Select all

^ KeyUp:        action=1 code=21 repeat=0 meta=1 scancode=0 mFlags=1024 label='' chars='null' number='' 
Try

Code: Select all

sendKey("DPAD_LEFT","SHIFT_MASK")
also doesn't work, cursor only move left.

Code: Select all

^ KeyUp:        action=1 code=21 repeat=0 meta=193 scancode=0 mFlags=1024 label='' chars='null' number='' 
Try

Code: Select all

sendKey("A","SHIFT_ON")
it sends a capital A, so the shift on actually works. Only not recognized when using with dpad.

Code: Select all

^ KeyDown:      action=0 code=29 repeat=0 meta=1 scancode=0 mFlags=1024 label='A' chars='null' number='' 
^ KeyUp:        action=1 code=29 repeat=0 meta=1 scancode=0 mFlags=1024 label='A' chars='null' number='' 
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

anuraag
Posts: 281
Joined: 24 Jan 2015 02:06

Re: send Keycode SHIFT+ARROW

Post by anuraag » 04 Jan 2019 09:39

CTRL+C, V, A, X working fine here.
Only problem with SHIFT.

User avatar
Desmanto
Posts: 2194
Joined: 21 Jul 2017 17:50

Re: send Keycode SHIFT+ARROW

Post by Desmanto » 05 Jan 2019 06:24

Oh. Just tested it, Ctrl version works fine. Seems can be useful in certain occassion. I think we also need the multiple meta key version. Something like CTRL+ALT+DEL, essentially 2 or more meta key at once
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

anuraag
Posts: 281
Joined: 24 Jan 2015 02:06

Re: send Keycode SHIFT+ARROW

Post by anuraag » 03 May 2019 04:48

I thought to continue my flow without shift option but now
Ctrl + Z works,
Ctrl + Y doesn't :cry:

User avatar
Desmanto
Posts: 2194
Joined: 21 Jul 2017 17:50

Re: send Keycode SHIFT+ARROW

Post by Desmanto » 03 May 2019 17:38

In which app, we can use Ctrl + Y ? In keyevent the Y is shown up, but I don't know if it is followed by the CTRL hold down.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

anuraag
Posts: 281
Joined: 24 Jan 2015 02:06

Re: send Keycode SHIFT+ARROW

Post by anuraag » 04 May 2019 00:19

On Android CTRL+SHIFT+Z is for redo operation. It is working with hacker's keyboard. So we need more than one metakey. Martin? :D

User avatar
Desmanto
Posts: 2194
Joined: 21 Jul 2017 17:50

Re: send Keycode SHIFT+ARROW

Post by Desmanto » 04 May 2019 01:17

Can't test that one using current sendKey(). Yes, we need additional meta key. Along with additional meta key "MENU" (keycode 82). I just found out that some chrome shortcut require "MENU" key, not "CTRL". It is lucky that the close tab can be done using "CTRL" + "W".
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

User avatar
Martin
Posts: 4413
Joined: 09 Nov 2012 14:23

Re: send Keycode SHIFT+ARROW

Post by Martin » 05 May 2019 13:24

Hi,

sendKey already allows to use multiple meta keys like this:
sendKey("A", "CTRL_ON", "SHIFT_ON");

The documentation does not mention this capability and the dialog only provides single meta key selection. I'll try to improve both.
I'm not sure why DPAD with SHIFT does not work. I will have to make a few experiments to see if there's a way to make this work. You could use function setSelection to achieve something similar in a less comfortable way.

Regards,
Martin

anuraag
Posts: 281
Joined: 24 Jan 2015 02:06

Re: send Keycode SHIFT+ARROW

Post by anuraag » 05 May 2019 17:25

That worked.

I don't know how to get start or end number for setSelection.

Post Reply