From 14dabb6f519275a800f1fbf13620f420555b0d0c Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Tue, 22 Feb 2022 19:32:16 +0100 Subject: Send key events for the modifiers Before sending a key event while modifiers are active, send events for the modifier keys. Some applications don't look at the "metaState" flags but instead keep track of the up and down events for the modifiers. For example, the basic text views that are in every applications correctly handle the "metaState" flags except for one binding: Selecting text with the arrows while pressing shift. --- srcs/juloo.keyboard2/Keyboard2.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2.java') diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 0ce3af8..44b36a1 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -256,14 +256,12 @@ public class Keyboard2 extends InputMethodService _keyboardView.setKeyboard(getLayout(res_id)); } - public void sendKeyEvent(int eventCode, int meta) + public void sendKeyEvent(int eventAction, int eventCode, int meta) { InputConnection conn = getCurrentInputConnection(); if (conn == null) return; - KeyEvent event = new KeyEvent(1, 1, KeyEvent.ACTION_DOWN, eventCode, 0, meta); - conn.sendKeyEvent(event); - conn.sendKeyEvent(KeyEvent.changeAction(event, KeyEvent.ACTION_UP)); + conn.sendKeyEvent(new KeyEvent(1, 1, eventAction, eventCode, 0, meta)); } public void showKeyboardConfig() -- cgit v1.2.3