diff --git a/src/g_editor.c b/src/g_editor.c
index 2ab2ffcb744d66763cc6d297048cdc65f3da353e..607e39b171504b519fb911cfc37cba17d8e8d54c 100644
--- a/src/g_editor.c
+++ b/src/g_editor.c
@@ -3121,6 +3121,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
     t_symbol *gotkeysym;
         
     int down, shift;
+	int focus = 1;
     
     if (ac < 3)
         return;
@@ -3159,6 +3160,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
 #if 0
     post("keynum %d, down %d, gotkeysym %s", (int)keynum, down, gotkeysym->s_name);
 #endif
+	if (ac == 4) focus = (int)(av[3].a_w.w_float);
     if (keynum == '\r') keynum = '\n';
     if (av[1].a_type == A_SYMBOL &&
         !strcmp(av[1].a_w.w_symbol->s_name, "Return"))
@@ -3201,12 +3203,12 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
             x->gl_editor->e_onmotion = MA_NONE;
             /* if an object has "grabbed" keys just send them on */
         if (x->gl_editor->e_grab
-            && x->gl_editor->e_keyfn && keynum)
+            && x->gl_editor->e_keyfn && keynum && focus)
                 (* x->gl_editor->e_keyfn)
                     (x->gl_editor->e_grab, (t_float)keynum);
             /* if a text editor is open send the key on, as long as
             it is either "real" (has a key number) or else is an arrow key. */
-        else if (x->gl_editor->e_textedfor && (keynum
+        else if (x->gl_editor->e_textedfor && focus && (keynum
             || !strcmp(gotkeysym->s_name, "Up")
             || !strcmp(gotkeysym->s_name, "Down")
             || !strcmp(gotkeysym->s_name, "Left")
@@ -3230,8 +3232,9 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
                 canvas_dirty(x, 1);
         }
             /* check for backspace or clear */
-        else if (keynum == 8 || keynum == 127)
+        else if ((keynum == 8 || keynum == 127) && focus)
         {
+			//fprintf(stderr,"backspace or clear\n");
             if (x->gl_editor->e_selectedline)
                 canvas_clearline(x);
             else if (x->gl_editor->e_selection)
diff --git a/src/pd.tk b/src/pd.tk
index 1d0340b7be993750eef89d2af27e009bd08df0d4..2c88b0f7de103764fc996dc1a58c4ea069ffd9de 100644
--- a/src/pd.tk
+++ b/src/pd.tk
@@ -763,7 +763,7 @@ proc pdtk_capture_root_window_keys {state key iso shift} {
 	# pdtk_post "$first_patch_window_name\n"
 
 	if { [string length $first_patch_window_name] > 0 } {
-		pdtk_canvas_sendkey $first_patch_window_name.c $state $key $iso $shift
+		pdtk_canvas_sendkey $first_patch_window_name.c $state $key $iso $shift 0
 	}
 }
 
@@ -2484,15 +2484,15 @@ proc pdtk_canvas_new {name width height geometry editable} {
     if {$pd_nt == 2} {
         bind $name.c <Mod1-Key> {pdtk_canvas_ctrlkey %W %K 0}
         bind $name.c <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %W %K 1}
-        bind $name.c <Mod1-BackSpace> {pdtk_canvas_sendkey %W 1 %K %A 0}
+        bind $name.c <Mod1-BackSpace> {pdtk_canvas_sendkey %W 1 %K %A 0 1}
         bind $name.c <Mod1-quoteleft> {menu_raisenextwindow}
     } else {
         bind $name.c <Control-Next>   {menu_raisenextwindow}
         #bind $name.c <Control-Prior>  {menu_raisepreviouswindow} ;# needs Tcl/Tk 8.5
 	}
-    bind $name.c <Key> {pdtk_canvas_sendkey %W 1 %K %A 0}
-    bind $name.c <Shift-Key> {pdtk_canvas_sendkey %W 1 %K %A 1}
-    bind $name.c <KeyRelease> {pdtk_canvas_sendkey %W 0 %K %A 0}
+    bind $name.c <Key> {pdtk_canvas_sendkey %W 1 %K %A 0 1}
+    bind $name.c <Shift-Key> {pdtk_canvas_sendkey %W 1 %K %A 1 1}
+    bind $name.c <KeyRelease> {pdtk_canvas_sendkey %W 0 %K %A 0 1}
     bind $name.c <Motion> {pdtk_canvas_motion %W %x %y 0}
     bind $name.c <Control-Motion> {pdtk_canvas_motion %W %x %y 2}
 	
@@ -2527,7 +2527,7 @@ proc pdtk_canvas_new {name width height geometry editable} {
     set pdtk_canvas_mouseup_name ""
 
 	bind $name <FocusIn> "menu_fixeditmenu $name"
-	bind $name <FocusOut> { pdtk_noselect %W }
+	# bind $name <FocusOut> { pdtk_noselect %W }
     focus $name.c
 }
 
@@ -3080,7 +3080,7 @@ proc pdtk_canvas_getscroll {name} {
     pdtk_canvas_checkgeometry [canvastosym $name]
 }
 
-proc pdtk_canvas_sendkey {name state key iso shift} {
+proc pdtk_canvas_sendkey {name state key iso shift focus} {
     global pd_nt
 	global ctrl_l_down
 	global ctrl_r_down
@@ -3141,7 +3141,7 @@ proc pdtk_canvas_sendkey {name state key iso shift} {
 		set state 1
 	}
 
-	pd [canvastosym $name] key $state $key $shift \;
+	pd [canvastosym $name] key $state $key $shift $focus\;
 }
 
 # only do actions if this is a canvas.