Basic support for backspace button

This commit is contained in:
Inez Korczynski 2012-01-26 01:47:37 +00:00
parent bc26561ada
commit b2db4c43eb
Notes: Gabriel Wicke 2012-02-27 16:40:01 +00:00

View file

@ -22,13 +22,21 @@ es.SurfaceView = function( $container, model ) {
};
es.SurfaceView.prototype.onKeyDown = function( e ) {
if ( e.which == 13 ) {
if ( e.which === 13 ) {
e.preventDefault();
var range = this.getSelection();
if ( range.start === range.end ) {
var tx = this.model.getDocument().prepareInsertion( range.start, [ { 'type': '/paragraph' }, { 'type': 'paragraph' } ]);
this.model.transact( tx );
}
} else if ( e.which === 8 ) {
console.log("A");
e.preventDefault();
var range = this.getSelection();
if ( range.start != range.end ) {
var tx = this.model.getDocument().prepareRemoval( range );
this.model.transact( tx );
}
}
};