0

I am creating a private webpage. I have a cursor i created from css, and a box also from css to mimic a textfield. THe reason i don't want to use text field is because of default cursor.

I sucessfully been able to move the cursor with switch statement for keyboard input. Switch because some keys are ignored and do other functions. I also created a backspace to return cursor to begining.

However, i have a few problems. My text field is 60% width, and i want to limit the cursor to only go to 58.58% to the right, the direction the text is going. When i try to do this using an if else inside the switch statement, and type 3 times a key, the cursor then jumps to the 58.58% mark on end of my created text field. How do i stop that. And secondly, i want to be able to display characters on the screen in over my text field to mimic a real one. But i cant seem to have any success.

Can anyone help.

My code below for the entire set up. Which hides placeholder text over the box, and allows backspace and type. H How do i limit cursor, and create character text to go over the box as i type and also allow characters to shift backwards once i reach the end of the text box?

$(document).keydown(function(e) {
var stoppos = $("#cursor").css("left");
switch(e.keyCode){
case 8:

if (stoppos < "10.15%") {
$("#cursor").css("background-color","#0000FF").css("left","0.15%");
$("#commandtext").show();
}   
else {
$("#cursor").css("left","-=15%");
}
break;
case 16:
$("#commandtext").show();
break;

/* Many more switch cases */

case 116:
$("#commandtext").show();
break;
default:            
$("#commandtext").hide();
$("#cursor").css("background-color","#0000FF").css("left","+=15%");
}
Marcelo
  • 4,395
  • 1
  • 18
  • 30

0 Answers0