Back or Screen On
This event simulates the back button if screen is on, or turns the screen on if screen is off.
Official Scrcpy client sends this event when the right mouse button is clicked. Clients can also use keyboard events to simulate the back and power button separately.
Options
interface ScrcpyBackOrScreenOnControlMessage {
action: AndroidKeyEventAction;
}
action: Ignored. The server will inject one key down and one key up event for the back button.(until v1.17) The action of the event. Allows long press on the back button. The client needs to send one key down event and one key up event to press and release the back button.(since v1.18)
Changelog
v1.15
actionfield is not supported and will be ignored. The server will inject one key down and one key up event for the back button.
v1.18
actionfield is added. The server will inject one key event with the specified action for the back button. The client needs to send one key down event and one key up event to press and release the back button.
Usage
- JavaScript
- TypeScript
import { AndroidKeyEventAction } from "@yume-chan/scrcpy";
// Using `ScrcpyControlMessageSerializer`
const message = serializer.backOrScreenOn(AndroidKeyEventAction.Down);
// Using `ScrcpyControlMessageWriter`
await writer.backOrScreenOn(AndroidKeyEventAction.Down);
// Using `AdbScrcpyClient`
await client.controller.backOrScreenOn(AndroidKeyEventAction.Down);
import { AndroidKeyEventAction } from "@yume-chan/scrcpy";
// Using `ScrcpyControlMessageSerializer`
const message: Uint8Array = serializer.backOrScreenOn(AndroidKeyEventAction.Down);
// Using `ScrcpyControlMessageWriter`
await writer.backOrScreenOn(AndroidKeyEventAction.Down);
// Using `AdbScrcpyClient`
await client.controller!.backOrScreenOn(AndroidKeyEventAction.Down);