jQuery Sanal Klavye

jQuery ve CSS kullanılarak hazırlanmış bir klavye uygulaması.
Bazen bildiğimiz programlama dilleri ile oynamak eğlenceli olabiliyor. CSS , online klavye oluşturmak için güzel olabilir, ve sonra jQuery ile çalışmasını sağladık düşündüm. Klavye tuşlarını işlemleri içermektedir.

HTML kodlarımız

Css kodalarımız

* {
margin: 0;
padding: 0;
}
body {
font: 71%/1.5 Verdana, Sans-Serif;
background: #eee;
}
#container {
margin: 100px auto;
width: 688px;
}
#write {
margin: 0 0 5px;
padding: 5px;
width: 671px;
height: 200px;
font: 1em/1.5 Verdana, Sans-Serif;
background: #fff;
border: 1px solid #f9f9f9;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#keyboard {
margin: 0;
padding: 0;
list-style: none;
}
#keyboard li {
float: left;
margin: 0 5px 5px 0;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
background: #fff;
border: 1px solid #f9f9f9;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.capslock, .tab, .left-shift {
clear: left;
}
#keyboard .tab, #keyboard .delete {
width: 70px;
}
#keyboard .capslock {
width: 80px;
}
#keyboard .return {
width: 77px;
}
#keyboard .left-shift {
width: 95px;
}
#keyboard .right-shift {
width: 109px;
}
.lastitem {
margin-right: 0;
}
.uppercase {
text-transform: uppercase;
}
#keyboard .space {
clear: left;
width: 681px;
}
.on {
display: none;
}
#keyboard li:hover {
position: relative;
top: 1px;
left: 1px;
border-color: #e5e5e5;
cursor: pointer;
}
Javascript kodlarımız

$(function(){
var $write = $(‘#write’),
shift = false,
capslock = false;

$(‘#keyboard li’).click(function(){
var $this = $(this),
character = $this.html(); // If it’s a lowercase letter, nothing happens to this variable

// Shift keys
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 letter
if ($this.hasClass(‘uppercase’)) character = character.toUpperCase();

// Remove shift once a key is clicked.
if (shift === true) {
$(‘.symbol span’).toggle();
if (capslock === false) $(‘.letter’).toggleClass(‘uppercase’);

shift = false;
}

// Add the character
$write.html($write.html() + character);
});
});
Proje Dosyalarımız
Örnek Uygulama

Both comments and pings are currently closed.

Comments are closed.


-- Dumlupinar Universitesi Bilişim Kulübü