I've been working on creating a mobile keyboard, but I'm facing some issues with the JavaScript part. The problem seems to be in my code as the keyboard isn't responding when I try to type. Here's a snippet of the JavaScript I'm using:
$(function() {
var $write = $('#write'),
shift = false,
capslock = false; // This section imports Jquery while defining variables for a textarea, shift status, and caps lock status.
$('#keyboard li').click(function() { // When a character (not a symbol) is clicked, two variables are created.
var $this = $(this),
character = $this.html(); // No changes made if it's a lowercase letter.
// Key press processing code here
});
});
// Shift key
if ($this.hasClass('left-shift') || $this.hasClass('right-shift')) {
$('.letter').toggleClass('uppercase');
$('.symbol span').toggle();
shift = (shift === true) ? false : true;
capslock = false;
return false;
}
// Caps lock
if ($this.hasClass('capslock')) {
$('.letter').toggleClass('uppercase');
capslock = true;
return false;
}
// Delete
if ($this.hasClass('delete')) {
var html = $write.html();
$write.html(html.substr(0, html.length - 1));
return false;
// Special characters
if ($this.hasClass('symbol')) character = $('span:visible', $this).html();
if ($this.hasClass('space')) character = ' ';
if ($this.hasClass('tab')) character = "\t";
if ($this.hasClass('return')) character = "\n";
// Uppercase letters
if ($this.hasClass('uppercase')) character = character.toUpperCase();
// Remove shift after key press
if (shift === true) {
$('.symbol span').toggle();
if (capslock === false) $('.letter').toggleClass('uppercase');
shift = false;
}
// Add the character
$write.html($write.html() + character);
});
Can anyone lend a hand? I've exhausted all my options trying to debug this on my own. Feel free to ask for more information if needed.