window.addEventListener("keydown", onPress_ENTER, false);
// Which I don't allow the 'enterkey' to be pressed
function onPress_ENTER(event){
var keyPressed = event.keyCode || event.which;
//if ENTER is pressed
if(keyPressed==13)
{
// Good here:
event.preventDefault();
stopImmediatePropagation();
// Do stuff here too:
}
else
{
return false;
}
}
Which works fine .
Since that
has focus I now want to insert a space ,
or actually 4 spaces " " .
Pls, how can this be done ?
Thanks
<script>
var someDots = "....";
var origContents = "";
var newContents = "";
function myFunction() {
origContents = document.getElementById("demo").innerHTML ;
newContents = origContents + someDots;
document.getElementById("demo").innerHTML = newContents;
}
</script>
But how do I determine which element was clicked ,
because there will be many paragraphs and the number of paragraphs changes dynamically ; and each paragraph won’t have an “id=” .
Thanks