diff --git a/pd/nw/index.js b/pd/nw/index.js
index 95195b20cb19ef48ee19bf10c9593a6437033bec..4237824b6e526661f972cf88cc40074aee64c4b0 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -510,7 +510,9 @@ function nw_create_pd_window_menus () {
     // Winman sub-entries
     winmanMenu.append(new gui.MenuItem({
         label: l("menu.nextwin"),
-        click: pdmenu_next_win,
+        click: function() {
+            pdgui.raise_next("pd_window");
+        },
         //key: "c",
         //modifiers: "ctrl",
         tooltip: l("menu.nextwin_tt")
@@ -518,7 +520,9 @@ function nw_create_pd_window_menus () {
 
     winmanMenu.append(new gui.MenuItem({
         label: l("menu.prevwin"),
-        click: pdmenu_previous_win,
+        click: function() {
+            pdgui.raise_prev("pd_window");
+        },
         //key: "a",
         //modifiers: "ctrl",
         tooltip: l("menu.prevwin_tt")
diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index cf2544a4d16295ce9923a7fba56cba444e1ea586..ab0b5fd5303f825422b412cb00c7374e4d32fc17 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -1218,7 +1218,9 @@ function nw_create_patch_window_menus(name) {
 
     winmanMenu.append(new gui.MenuItem({
         label: l("menu.nextwin"),
-        click: menu_generic,
+        click: function() {
+            pdgui.raise_next(name);
+        },
         key: String.fromCharCode(12), // Page down
         modifiers: "ctrl",
         tooltip: l("menu.nextwin_tt"),
@@ -1226,7 +1228,9 @@ function nw_create_patch_window_menus(name) {
 
     winmanMenu.append(new gui.MenuItem({
         label: l("menu.prevwin"),
-        click: menu_generic,
+        click: function() {
+            pdgui.raise_prev(name);
+        },
         key: String.fromCharCode(11), // Page up
         modifiers: "ctrl",
         tooltip: l("menu.prevwin_tt"),
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 0991bdfcc7b55a1648cae6b39c1dc18d6c120f24..d322b83e8d09721c19a6ba0b048ca15ab778d760 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -40,6 +40,16 @@ exports.get_local_string = lang.get_local_string;
 var pd_window; 
 exports.pd_window;
 
+// Turns out I messed this up. pd_window should really be an
+// "nw window", so that you can use it to access all the
+// nw window methods and settings.  Instead I set it to the
+// DOM window object. This complicates things-- for example,
+// in walk_window_list I have to take care when comparing
+// patchwin[]-- which are nw windows-- and pd_window.
+// I'm not sure of the best way to fix this. Probably we want to
+// just deal with DOM windows, but that would mean abstracting
+// out the stuff that deals with nw window size and
+// positioning.
 exports.set_pd_window = function(win) {
     pd_window = win;
     exports.pd_window = win;
@@ -2897,9 +2907,47 @@ function gui_raise_window(cid) {
 }
 
 function gui_raise_pd_window() {
-    pd_window.focus();
+    pd_window.focus(-1);
+}
+
+// Walk the list of open patch windows. They are walked in the order
+// they were created.
+// This is a bit complicated because of the way I set pd_window above
+function walk_window_list(cid, offset) {
+    var win_store = global.__nwWindowsStore,
+        my_win = cid === "pd_window" ? pd_window : patchwin[cid].window,
+        id_array = [],
+        my_id, id, next_id;
+    for (id in win_store) {
+        if (win_store.hasOwnProperty(id)) {
+            id_array.push(+id); // build array of numbers
+            if (win_store[id].window === my_win) {
+                my_id = +id; // cast as number to match against array
+            }
+        }
+    }
+    id_array.sort(function(a, b) { return a-b; }); // sort numerically
+    next_id = (id_array.indexOf(my_id) + offset);
+    if (next_id < 0) {
+        next_id += id_array.length;
+    } else {
+        next_id %= id_array.length;
+    }
+    win_store[id_array[next_id]].focus();
 }
 
+function raise_next(cid) {
+    walk_window_list(cid, 1);
+}
+
+exports.raise_next = raise_next;
+
+function raise_prev(cid) {
+    walk_window_list(cid, -1);
+}
+
+exports.raise_prev = raise_prev;
+
 exports.raise_pd_window= gui_raise_pd_window;
 
 // Openpanel and Savepanel
diff --git a/pd/nw/todo.txt b/pd/nw/todo.txt
index ee3f75e8f61b0cfb6a52bbd6477adcc78f4d6bb3..b63b94cafc5cdac1b91427fd5f9a7b385b68152d 100644
--- a/pd/nw/todo.txt
+++ b/pd/nw/todo.txt
@@ -325,6 +325,8 @@ Everything else: (A [x] means we've fixed it)
     that isn't true. Thus if we open many patches at a time, the getscroll
     call for the most recent window will cancel the old one, leaving the 
     older window with the wrong viewport.
+[ ] fix the Next Window/Previous Window keybindings. For some reason they
+    don't work.
 
 Crashers
 --------