How to detect whether custom keyboard is activated from the keyboard’s container app?

Here is a method I have used in one of my projects. I think it is what you asked for, hope it helps you. – (BOOL)isCustomKeyboardEnabled { NSString *bundleID = @”com.company.app.customkeyboard”; // Replace this string with your custom keyboard’s bundle ID NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@”AppleKeyboards”]; // Array of all active keyboards for … Read more

How to grab keyboard events on an element which doesn’t accept focus?

A div by default cannot be given focus. However, you can change that by adding a tabindex attribute to the div: <div tabindex=”0″ id=”example”></div> You can then give the div focus, and also blur it with the hover event: $(“#example”).hover(function() { this.focus(); }, function() { this.blur(); }).keydown(function(e) { alert(e.keyCode); }); When the div has focus, … Read more

How to dismiss keyboard iOS programmatically when pressing return

The simple way is to connect the delegate of UITextField to self (self.mytestField.delegate = self) and dismiss the keyboard in the method textFieldShouldReturn using [textField resignFirstResponder]; Another way to dismiss the keyboard is the following: Objective-C [self.view endEditing:YES]; Swift: self.view.endEditing(true) Put [self.view endEditing:YES]; where you would like to dismiss the keyboard (Button event, Touch event, … Read more

How do I ‘lock the keyboard’ to prevent any more keypresses being sent on X11/Linux/Gnome?

Based on that, here’s a code I came up with: class KeyboardLocker: def __init__(self, serio=0): self._on = False self.serio = serio def on(self): return self._on def write_value(self,path, value): with open(path, “a”) as f: f.write(value) def toggle(self): if self.on(): self.turn_off() else: self.turn_on() def description(self): path=”/sys/devices/platform/i8042/serio%d/description” % (self.serio,) with open(path, “r”) as f: description = f.read() return … Read more

Change keyboard layout from C# code with .NET 4.5.2

Switching the keyboard layout requires some P/Invoke; you´ll need at least the following Windows functions to get it working: LoadKeyboardLayout, GetKeyboardLayout and ActivateKeyboardLayout. The following import declarations worked for me… [DllImport(“user32.dll”, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = “LoadKeyboardLayout”, SetLastError = true, ThrowOnUnmappableChar = false)] static extern uint LoadKeyboardLayout( StringBuilder pwszKLID, uint flags); [DllImport(“user32.dll”, … Read more

Change Keyboard Input Language Programmatically

You can change keyboard without user notification only and only if your app is running as a System app for security reasons. You need to give Android permission first in your app’s AndroidManifest.xml “android.permission.WRITE_SECURE_SETTINGS” Then you need to determine id of your keyboard. -> To know id, you need to keep your keyboard default from … Read more

EditText with soft keyboard and “Back” button

You can override when the keyboard disappears using this method: public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { // Do your thing here return false; } return super.dispatchKeyEvent(event); } Taken from my other answer @ : Android: Error popup on EditText doesn’t move down when keyboard goes … Read more

Soft Keyboard shows up on EditText focus ONLY once

Try to open and hide inside a Runnable as, TO OPEN ettext.requestFocus(); ettext.postDelayed(new Runnable() { @Override public void run() { InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(ettext, 0); } },200); TO CLOSE ettext.requestFocus(); ettext.postDelayed(new Runnable() { @Override public void run() { InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.hideSoftInputFromWindow(ettext. getWindowToken(), 0); } },200);

tech