So this is my problem, my code works fine and when i press space from my physical keyboard it does what it supposed to, but when i press space on soft keyboard, it doesn't work. I tried running my code with KEYCODE_ENTER and it is actually working fine on both hard and soft keyboard.
This is my code:
editTextInput.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_UP) && (keyCode == KeyEvent.KEYCODE_SPACE)) {
//If paragraph contains the word then it returns true, thus increasing wordCount by 1
if(paragraphToArray(testParagraph,search) == true)
{
wordCount += 1;
}
if(wordCount == 1)
{
startTimer();
}
//Clearing the editTextInput edit area.
editTextInput.setText("");
//search = "";
search.replace(0,30,"");
return true;
}
return false;
}
});