For the goal to be achieved precisely we need Xposed Additions Pro and Tasker installed, where the former requires root access and Xposed Framework (stable build) installed.
Once you install the Xposed Additions, you'll be asked to activate its module in Xposed Framework. Activate it.
We'll be using Xposed Addition's ability to intercept a key-press and would provide a condition and action to be performed for that key-press. We'll use Tasker to circumvent Xposed Addition's limited set of options.
Note: All sections tested on Android 4.4.2 and 5.0.2.
Instructions for Xposed Additions
- Launch Xposed Additions → tap Buttons
- Tap Add new key
- Press the device's button to be used as a keyboard's ↑ key
- I chose Volume Up/+ button
- Tap the entry for the button you chose earlier
- Tap Add new Condition
- Tap Load Applications List
- Select the app where you want Volume Up button to simulate a keyboard's ↑ key
- Tap your previously selected app's entry
- Check the box to activate Click
- Tap Click
- Choose DPad Up aka Directional Pad Up -- it's a KeyEvent
(Click image to enlarge; hover to know details)
(Order of images: Follow images from left to right in each row)

Now create an action for Volume Down/- button in aforesaid manner but choose DPad Down at final step.

It is time you launch the app you selected in the said steps and try pressing Volume Up and Volume Down buttons. They will work as a keyboard's ↑ ↓ directional keys.
Note that contrary to a physical keyboard where if you hold a directional key the system will continue to scroll up/down, this is not the behavior you would observe if you long-press your (aforesaid selected) device's buttons.
Also, in place of choosing DPad Up and DPad Down, choose Page Up and Page Down to simulate a keyboard's Pg Up and Pg Dn key or assign them to a different action listed in step 10.
And, don't bother about ringtone or speaker sound level since they would be managed by long pressing those Volume Up and Volume Down buttons. This behavior is valid when your aforesaid selected app is launched.
I've tested successfully the aforesaid solution on Chrome, Firefox, and some text editors. So far so good!
Nope! The said solution is not good for all applications. We want to cover all applications, so why limit to web browsers and text editors only.
Unfortunately, there are apps on which the said solution doesn't work. The KeyEvents we used there seem to have no effect on apps like Foxit MobilePDF, WPS Office, BetterbatteryStats, and more in the wild.
Let's focus on a new solution now. Android allows sending swipes using input
command; Xposed Additions allows using a custom shortcut as an action; Tasker can create a custom shortcut to use input swipe
.
Instructions for Tasker and Xposed Additions
We first need the swipe's start and end (X and Y) coordinates to use them in input
command. We can record it using Getevent command.
Setup adb in your PC, plug the device into PC, enable USB debugging in device, launch a shell on PC, and enter:
adb shell su -c 'getevent -l'
It would show some lines and then would wait indefinitely for output.
It is time you decide the length of your swipe as an alternative to DPad Up / Page Up.
E.g. The arrow length measuring a swipe in the two images is an alternative to scrolling length of DPad Up/Down and Page Up/Down respectively.

When you would make a swipe on the screen, the shell on PC would show output like:
/dev/input/event0: EV_ABS ABS_MT_TRACKING_ID 0000044c
/dev/input/event0: EV_KEY BTN_TOUCH DOWN
/dev/input/event0: EV_KEY BTN_TOOL_FINGER DOWN
/dev/input/event0: EV_ABS ABS_MT_POSITION_X 00000300
/dev/input/event0: EV_ABS ABS_MT_POSITION_Y 000006de
/dev/input/event0: EV_ABS ABS_MT_PRESSURE 000000c0
/dev/input/event0: EV_ABS ABS_MT_TOUCH_MINOR 00000004
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_SYN SYN_REPORT 00000000
...
/dev/input/event0: EV_ABS ABS_MT_POSITION_X 000002fb
/dev/input/event0: EV_ABS ABS_MT_POSITION_Y 000004e3
/dev/input/event0: EV_ABS ABS_MT_PRESSURE 000000cc
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_ABS ABS_MT_PRESSURE 000000c8
After making an upward swipe of specific length, press Ctrl+C in PC to stop the command.
In its output note the first ABS_MT_POSITION_X (00000300
) and ABS_MT_POSITION_Y (000006de
), and last ABS_MT_POSITION_X (000002fb
) and ABS_MT_POSITION_Y (000004e3
) entries. They are the start (X1,Y1) and end (X2,Y2) coordinates in hexadecimal form. Convert them into decimal form (try a converter here).
In the shell, if you enter:
adb shell input touchscreen swipe X1 Y1 X2 Y2
(replace X1, Y1, and X2, Y2 with the now converted decimal coordinates) you would notice an upward swipe on the device effectively simulating scroll down. Manipulate those coordinates until you get your ideal scroll down.
As an alternative of using Getevent, you can try a more friendly approach.
Enable Pointer Location under Developer options. Once you enable it your device's status bar would get covered with a bar showing some coordinates which would change with the movement of your tap/swipe on screen.
Time to record your swipe length. Touch and hold your finger on screen and note X:
and Y:
shown at the top. Start swiping up the finger to the desired length; stop but don't release the finger and note down the corresponding X:
and Y:
coordinates.
Those are the X1, Y1 and X2, Y2 coordinates for your up swipe. They are in decimal form, so you can directly use them in input
command.
You can choose to disable the Pointer locations now.
Instructions specific to Tasker
We would now create a shortcut to simulate the swipe we manually performed in the last command, for the purpose of automating it.
- Launch Tasker and enable it. If its icon above Profiles tab is lit, then it's already active. Note that everything in Tasker is saved by pressing the back button, which would also change the active window.
- Create a task under Tasks via
+
(at the bottom) → name it (say Scroll Down
).
Create an action in it through +
→Code → Run Shell, and enter these details:
Command: input touchscreen swipe X1 Y1 X2 Y2
Replace the X1, X2, and Y1, Y2 with the coordinates you noted earlier. E.g. input touchscreen swipe 768 1758 763 1251
.
Check Use Root
- Store Errors In:
%sd_err
-- this step is optional.
- Create a new task named
Scroll Up
, and create an action in it by following step 3. For swipe down simulation simply interchange the coordinates, so it would be input swipe X2 Y2 X1 Y1
, and optionally use %su_err
to store errors, if occur!
Instructions to use Task shortcuts in Xposed Additions
This is the final phase of the solution and would use those custom shortcuts in Xposed Additions.
- Follow the steps 1-11 in the first section dealing with the usage of Xposed Additions
- Choose Shortcut instead of DPad Up or Page Up
- Choose Task Shortcut → Scroll Up
- Choose 3x3 square boxes icon at the bottom
- Choose an icon and come back to Xposed Additions.
- Repeat the aforesaid steps 1-5 for Volume Down and select Scroll Down in it. You get the idea by now what to do every time.

I've compiled a video showing the whole answer in action. Here it is. Mind the quality because it is heavily ripped from 100MB to 7.1MB.
Cheers!