Android Question Stop soft keyboard from closing when back key pressed

JackKirk

Well-Known Member
Licensed User
Longtime User
Is there any way to prevent the soft keyboard from closing when the back key is pressed?

Alternatively, is there any way to set up an event to trap when the soft keyboard is closed via the back key being pressed?

I can't seem to find anything on the forums that directly address this - which is puzzling because I would have thought it would be a common requirement.

EDIT: I should add that I have tried monitoring activity height via the IME library without success - all the relevant EditText views are inside a class.

Thanks in advance...
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
OK, I had another crack at the IME approach and got it working.

2 problems:

(1) You have to declare and use the IME library from the activity (this was my snag - obvious in retrospect) - ie trap the change in height via IME_HeightChanged event in activity - then notify the class instance via a dedicated method in the class which then can take appropriate actions in the class. This is all very messy, convoluted and decidedly unclassy (if you pardon the very poor pun) - and you have to set it up for every activity in the application.

(2) It does not serve the purpose of setting up an event to trap when the soft keyboard is closed via the back key being pressed when the keyboard is floating (see image) because there is no height change of the view.

floating keyboard.png


So another question: is there any way to prevent the keyboard from floating - ie suppress the floating option in the keyboard?

Thanks again...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
I'm using a Samsung S5 which as far as I am aware is stock standard.

Under [Settings/Language and input] It appears to have a "Samsung keyboard" with no obvious options to change it.

This would have to make it up in the category of "most keyboards" surely.

EDIT: just installed the Google keyboard from the play store - this one doesn't have a floating option - of course can't rely on my apps users to oblige by ensuring they have a non-floating keyboard - so my app is left with a small but findable wormhole thru which a user could crawl.
 
Last edited:
Upvote 0
Top