I'm not sure I entirely understand what you are trying to do but it seems that you wish to capture user input into a div with the contentEditable attribute. If I were using Mootools and Firebug I would begin with the following::
$('idOfEditableDiv').addEvent('keydown', function(event) {
console.log(event.key);
});
That will print into the Firebug console any key that is pressed inside the content editable div. So if I press the 'a' key, 'a' will be printed. This can be useful if you are looking to capture input that doesn't have an obvious value such as the Caps Lock key. Logging the entire event with console.log(event)
can give you even more useful information.
When you have identified which keys you wish to capture (say the a and b keys), then do the following:
$('idOfEditableDiv').addEvent('keydown', function(event) {
if(event.key == 'a' || event.key == 'b') {
//do stuff here if the a or b key was pressed
}
});
Sometimes you might want to do stuff if the a key was pressed and other stuff if the b key was pressed. In that case, do the following:
$('idOfEditableDiv').addEvent('keydown', function(event) {
if(event.key == 'a') {
//do stuff here if the a key was pressed
}
else if(event.key == 'b') {
//do stuff here if the b key was pressed
}
});
In case you aren't familiar with Mootools, you would need to wrap all your Mootools code in a domReady event like this:
window.addEvent('domready', function() {
$('idOfEditableDiv').addEvent('keydown', function(event) {
if(event.key == 'a') {
//do stuff here if the a key was pressed
}
else if(event.key == 'b') {
//do stuff here if the b key was pressed
}
});
});
More information about Mootools Events