I'm working on a jquery crossword puzzle plugin and for the iOS version I have it so that when a cell is clicked a function is called which uses .focus() to being up the touch screen keyboard. I also have it set up so that when a letter key is pressed it will move to the next cell and call that same click event and be ready for input. This works fine on PC but for some reason a regular click brings up the keyboard but not when it's called after pressing a key. The cells are divs withn an input tag inside.
Here's my code:
function cellClick( event )
{
moveToCell( "#" + event.currentTarget.id );
_cwo.onWord = false;
var dir = getNewDirection(_cwo.currRow, _cwo.currCol);
_cwo.direction = dir;
alignClue( "A", _cwo.clues["across"] );
alignClue( "D", _cwo.clues["down"] );
};
function moveToCell( id ) // put the cursor in the given cell
{
$( _cwo.currCell).css( 'background-color', 'white');
$( id).css( 'background-color', _cwo.currentCellColor );
_cwo.currRow = $(id).data('row');
_cwo.currCol = $(id).data('col');
_cwo.currCell = "#" + cellID( _cwo.currRow, _cwo.currCol );
$(_cwo.currCell).focus();
};
function keyUp( event )
{
if ( event.currentTarget.tagName != "HTML" ) return;
if(event.which == 13){
var dir = getDirection(_cwo.currRow, _cwo.currCol);
if(dir == "across")goAcross(true);
else
goDown(true);
}
if (
( 32 == event.which ) ||
( ( 64 < event.which ) && ( event.which < 91 ) ) ||
( ( 96 < event.which ) && ( event.which < 123 ) )
)
{
_char = codeToChar( event.which );
if ( _char == _cwo.NA ) return;
$( _cwo.currCell).data( 'player', _char );
paintCell( _cwo.currCell, 'player');
if( _cwo.direction == 'across')goAcross( false );
if( _cwo.direction == 'down')goDown();
}
alignClue( "A", _cwo.clues["across"] );
alignClue( "D", _cwo.clues["down"] );
$("#" + cellID( _cwo.currRow, _cwo.currCol )).click(); //calls cellClick
};
//Will prevent keys from being repeated on input
$('*').keydown(function(e){
e.preventDefault();
});