Reviewed by Kevin Ollivier.
authorkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 May 2009 00:51:02 +0000 (00:51 +0000)
committerkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 May 2009 00:51:02 +0000 (00:51 +0000)
Full Keyboard shortcut support.
Implement wxBrowser Cut/Copy/Paste menu items.

https://bugs.webkit.org/show_bug.cgi?id=24797

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@43265 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/ScrollView.cpp
WebCore/platform/wx/KeyboardEventWx.cpp
WebCore/platform/wx/ScrollViewWx.cpp
WebKit/wx/ChangeLog
WebKit/wx/WebBrowserShell.cpp
WebKit/wx/WebBrowserShell.h
WebKit/wx/WebKitSupport/EditorClientWx.cpp
WebKit/wx/WebKitSupport/EditorClientWx.h
WebKit/wx/WebView.cpp

index 1089465..7acc695 100644 (file)
@@ -1,3 +1,19 @@
+2009-04-01  miggilin  <mr.diggilin@gmail.com>
+
+        Reviewed by Kevin Ollivier.
+
+        Mouse wheel scrolling and keyboard shortcut support for wx.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=24797
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::wheelEvent):
+        * platform/wx/KeyboardEventWx.cpp:
+        (WebCore::windowsKeyCodeForKeyEvent):
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+        * platform/wx/ScrollViewWx.cpp:
+        (WebCore::ScrollView::platformSetScrollPosition):
+
 2009-05-05  Kevin Ollivier  <kevino@theolliviers.com>
 
         wx build fix for Windows, add missing include.
index 751d0e1..28fe1c5 100644 (file)
@@ -632,8 +632,13 @@ Scrollbar* ScrollView::scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent)
 void ScrollView::wheelEvent(PlatformWheelEvent& e)
 {
     // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
-    if (!canHaveScrollbars() || platformWidget())
+#if PLATFORM(WX)
+    if (!canHaveScrollbars()) {
+#else
+    if (!canHaveScrollbars() || platformWidget()) {
+#endif
         return;
+    }
 
     // Determine how much we want to scroll.  If we can move at all, we will accept the event.
     IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition();
index cce83ed..7f57073 100644 (file)
@@ -162,14 +162,17 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode)
             return VK_DECIMAL; // (6E) Decimal key
         case WXK_DIVIDE:
             return VK_DIVIDE; // (6F) Divide key
-
+        case WXK_NUMPAD_SEPARATOR:
+            return VK_SEPARATOR;
         
         case WXK_BACK:
             return VK_BACK; // (08) BACKSPACE key
         case WXK_TAB:
+        case WXK_NUMPAD_TAB:
             return VK_TAB; // (09) TAB key
         case WXK_CLEAR:
             return VK_CLEAR; // (0C) CLEAR key
+        case WXK_NUMPAD_ENTER:
         case WXK_RETURN:
             return VK_RETURN; //(0D) Return key
         case WXK_SHIFT:
@@ -203,22 +206,31 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode)
             // VK_NONCONVERT (1D) IME nonconvert
             // VK_ACCEPT (1E) IME accept
             // VK_MODECHANGE (1F) IME mode change request
+        case WXK_NUMPAD_SPACE:
         case WXK_SPACE:
             return VK_SPACE; // (20) SPACEBAR
+        case WXK_NUMPAD_PAGEUP:
         case WXK_PAGEUP:
             return VK_PRIOR; // (21) PAGE UP key
+        case WXK_NUMPAD_PAGEDOWN:
         case WXK_PAGEDOWN:
             return VK_NEXT; // (22) PAGE DOWN key
+        case WXK_NUMPAD_END:
         case WXK_END:
             return VK_END; // (23) END key
+        case WXK_NUMPAD_HOME:
         case WXK_HOME:
             return VK_HOME; // (24) HOME key
+        case WXK_NUMPAD_LEFT:
         case WXK_LEFT:
             return VK_LEFT; // (25) LEFT ARROW key
+        case WXK_NUMPAD_UP:
         case WXK_UP:
             return VK_UP; // (26) UP ARROW key
+        case WXK_NUMPAD_RIGHT:
         case WXK_RIGHT:
             return VK_RIGHT; // (27) RIGHT ARROW key
+        case WXK_NUMPAD_DOWN:
         case WXK_DOWN:
             return VK_DOWN; // (28) DOWN ARROW key
         case WXK_SELECT:
@@ -227,11 +239,12 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode)
             return VK_PRINT; // (2A) PRINT key
         case WXK_EXECUTE:
             return VK_EXECUTE;// (2B) EXECUTE key
-            //dunno on this
-            //case WXK_PrintScreen:
-            //      return VK_SNAPSHOT; // (2C) PRINT SCREEN key
+        case WXK_SNAPSHOT:
+             return VK_SNAPSHOT; // (2C) PRINT SCREEN key
+        case WXK_NUMPAD_INSERT:
         case WXK_INSERT:
             return VK_INSERT; // (2D) INS key
+        case WXK_NUMPAD_DELETE:
         case WXK_DELETE:
             return VK_DELETE; // (2E) DEL key
         case WXK_HELP:
@@ -335,7 +348,15 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event)
     if (m_type != Char)
         m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode());
     else {
-        m_text = wxString(event.GetUnicodeKey());
+        //ENTER is an editing command processed as a char (only Enter and Tab are)
+        //unfortunately the unicode key for numpad_enter (370) is NOT what we want here (13)
+        //The unicode values for normal enter and tab are the same as the ASCII values, thus ok
+        //Note that I think this a wx bug, as the Character Code is actually 13 when
+        //numpad_enter is a CHAR event.
+        if (event.GetKeyCode() == 13 && event.GetUnicodeKey() == wxChar(370))
+            m_text = "\r";
+        else
+            m_text = wxString(event.GetUnicodeKey());
         m_unmodifiedText = m_text;
     }
     m_autoRepeat = false; // FIXME: not correct.
index 2813e0c..f556894 100644 (file)
@@ -191,12 +191,12 @@ void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint)
     if (newScrollOffset.x < 0)
         newScrollOffset.x = 0;
     else if (newScrollOffset.x + cRect.width > vRect.width)
-        newScrollOffset.x = max(0, vRect.width - cRect.width - 1);
+        newScrollOffset.x = max(0, vRect.width - cRect.width);
 
     if (newScrollOffset.y < 0)
         newScrollOffset.y = 0;
     else if (newScrollOffset.y + cRect.height > vRect.height)
-        newScrollOffset.y = max(0, vRect.height - cRect.height - 1);
+        newScrollOffset.y = max(0, vRect.height - cRect.height);
 
     if (newScrollOffset == scrollOffset)
         return;
index 7ce2ce0..0b4fb54 100644 (file)
@@ -1,3 +1,30 @@
+2009-04-01  miggilin  <mr.diggilin@gmail.com>
+
+        Reviewed by Kevin Ollivier.
+
+        Full Keyboard shortcut support.
+        Implement wxBrowser Cut/Copy/Paste menu items.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=24797
+
+        * WebBrowserShell.cpp:
+        (wxWebBrowserShell::OnSearchCtrlEnter):
+        (wxWebBrowserShell::OnCut):
+        (wxWebBrowserShell::OnCopy):
+        (wxWebBrowserShell::OnPaste):
+        * WebBrowserShell.h:
+        * WebKitSupport/EditorClientWx.cpp:
+        (WebCore::):
+        (WebCore::EditorClientWx::handleEditingKeyboardEvent):
+        (WebCore::EditorClientWx::interpretKeyEvent):
+        (WebCore::EditorClientWx::handleKeyboardEvent):
+        * WebKitSupport/EditorClientWx.h:
+        * WebView.cpp:
+        (wxWebView::CanCut):
+        (wxWebView::CanPaste):
+        (wxWebView::Paste):
+        (wxWebView::OnKeyEvents):
+
 2009-05-05  Maclolm MacLeod  <mmacleod@webmail.co.za>
 
         Reviewed by Kevin Ollivier.
index d2a30d5..8853051 100644 (file)
@@ -67,6 +67,9 @@ enum {
 };
 
 BEGIN_EVENT_TABLE(wxWebBrowserShell, wxFrame)
+    EVT_MENU(wxID_CUT, wxWebBrowserShell::OnCut)
+    EVT_MENU(wxID_COPY, wxWebBrowserShell::OnCopy)
+    EVT_MENU(wxID_PASTE, wxWebBrowserShell::OnPaste)
     EVT_MENU(wxID_EXIT,  wxWebBrowserShell::OnQuit)
     EVT_MENU(wxID_ABOUT, wxWebBrowserShell::OnAbout)
     EVT_MENU(ID_LOADFILE, wxWebBrowserShell::OnLoadFile)
@@ -252,6 +255,24 @@ void wxWebBrowserShell::OnSearchCtrlEnter(wxCommandEvent& event)
     }
 }
 
+void wxWebBrowserShell::OnCut(wxCommandEvent& event)
+{
+    if (webview && webview->CanCut())
+        webview->Cut();
+}
+
+void wxWebBrowserShell::OnCopy(wxCommandEvent& event)
+{
+    if (webview && webview->CanCopy())
+        webview->Copy();
+}
+
+void wxWebBrowserShell::OnPaste(wxCommandEvent& event)
+{
+    if (webview && webview->CanPaste())
+        webview->Paste();
+}
+
 void wxWebBrowserShell::OnBack(wxCommandEvent& event)
 {
     if (webview)
index 9b48314..edda9e4 100644 (file)
@@ -55,6 +55,9 @@ public:
 protected:
 
     // event handlers (these functions should _not_ be virtual)
+    void OnCut(wxCommandEvent& event);
+    void OnCopy(wxCommandEvent& event);
+    void OnPaste(wxCommandEvent& event);
     void OnQuit(wxCommandEvent& event);
     void OnAbout(wxCommandEvent& event);
     void OnLoadFile(wxCommandEvent& event);
index 9e81a6b..da0c5af 100644 (file)
 
 namespace WebCore {
 
+static const unsigned CtrlKey = 1 << 0;
+static const unsigned AltKey = 1 << 1;
+static const unsigned ShiftKey = 1 << 2;
+
+struct KeyDownEntry {
+    unsigned virtualKey;
+    unsigned modifiers;
+    const char* name;
+};
+
+struct KeyPressEntry {
+    unsigned charCode;
+    unsigned modifiers;
+    const char* name;
+};
+
+static const KeyDownEntry keyDownEntries[] = {
+    { VK_LEFT,   0,                  "MoveLeft"                                    },
+    { VK_LEFT,   ShiftKey,           "MoveLeftAndModifySelection"                  },
+    { VK_LEFT,   CtrlKey,            "MoveWordLeft"                                },
+    { VK_LEFT,   CtrlKey | ShiftKey, "MoveWordLeftAndModifySelection"              },
+    { VK_RIGHT,  0,                  "MoveRight"                                   },
+    { VK_RIGHT,  ShiftKey,           "MoveRightAndModifySelection"                 },
+    { VK_RIGHT,  CtrlKey,            "MoveWordRight"                               },
+    { VK_RIGHT,  CtrlKey | ShiftKey, "MoveWordRightAndModifySelection"             },
+    { VK_UP,     0,                  "MoveUp"                                      },
+    { VK_UP,     ShiftKey,           "MoveUpAndModifySelection"                    },
+    { VK_PRIOR,  ShiftKey,           "MovePageUpAndModifySelection"                },
+    { VK_DOWN,   0,                  "MoveDown"                                    },
+    { VK_DOWN,   ShiftKey,           "MoveDownAndModifySelection"                  },
+    { VK_NEXT,   ShiftKey,           "MovePageDownAndModifySelection"              },
+    { VK_PRIOR,  0,                  "MovePageUp"                                  },
+    { VK_NEXT,   0,                  "MovePageDown"                                },
+    { VK_HOME,   0,                  "MoveToBeginningOfLine"                       },
+    { VK_HOME,   ShiftKey,           "MoveToBeginningOfLineAndModifySelection"     },
+    { VK_HOME,   CtrlKey,            "MoveToBeginningOfDocument"                   },
+    { VK_HOME,   CtrlKey | ShiftKey, "MoveToBeginningOfDocumentAndModifySelection" },
+
+    { VK_END,    0,                  "MoveToEndOfLine"                             },
+    { VK_END,    ShiftKey,           "MoveToEndOfLineAndModifySelection"           },
+    { VK_END,    CtrlKey,            "MoveToEndOfDocument"                         },
+    { VK_END,    CtrlKey | ShiftKey, "MoveToEndOfDocumentAndModifySelection"       },
+
+    { VK_BACK,   0,                  "DeleteBackward"                              },
+    { VK_BACK,   ShiftKey,           "DeleteBackward"                              },
+    { VK_DELETE, 0,                  "DeleteForward"                               },
+    { VK_BACK,   CtrlKey,            "DeleteWordBackward"                          },
+    { VK_DELETE, CtrlKey,            "DeleteWordForward"                           },
+    
+    { 'B',       CtrlKey,            "ToggleBold"                                  },
+    { 'I',       CtrlKey,            "ToggleItalic"                                },
+
+    { VK_ESCAPE, 0,                  "Cancel"                                      },
+    //FIXME: this'll never happen. We can trash it or make it a normal period
+    { VK_OEM_PERIOD, CtrlKey,        "Cancel"                                      },
+    { VK_TAB,    0,                  "InsertTab"                                   },
+    { VK_TAB,    ShiftKey,           "InsertBacktab"                               },
+    { VK_RETURN, 0,                  "InsertNewline"                               },
+    { VK_RETURN, CtrlKey,            "InsertNewline"                               },
+    { VK_RETURN, AltKey,             "InsertNewline"                               },
+    { VK_RETURN, AltKey | ShiftKey,  "InsertNewline"                               },
+    { 'A',       CtrlKey,            "SelectAll"                                   },
+    { 'Z',       CtrlKey,            "Undo"                                        },
+    { 'Z',       CtrlKey | ShiftKey, "Redo"                                        },
+};
+
+static const KeyPressEntry keyPressEntries[] = {
+    { '\t',   0,                  "InsertTab"                                   },
+    { '\t',   ShiftKey,           "InsertBacktab"                               },
+    { '\r',   0,                  "InsertNewline"                               },
+    { '\r',   CtrlKey,            "InsertNewline"                               },
+    { '\r',   AltKey,             "InsertNewline"                               },
+    { '\r',   AltKey | ShiftKey,  "InsertNewline"                               },
+};
+
 EditorClientWx::~EditorClientWx()
 {
     m_page = NULL;
@@ -286,6 +361,74 @@ void EditorClientWx::redo()
     }
 }
 
+bool EditorClientWx::handleEditingKeyboardEvent(KeyboardEvent* event)
+{
+    Node* node = event->target()->toNode();
+    ASSERT(node);
+    Frame* frame = node->document()->frame();
+    ASSERT(frame);
+
+    const PlatformKeyboardEvent* keyEvent = event->keyEvent();
+
+    //NB: this is what windows does, but they also have a keypress event for Alt+Enter which clearly won't get hit with this
+    if (!keyEvent || keyEvent->altKey())  // do not treat this as text input if Alt is down
+        return false;
+
+    Editor::Command command = frame->editor()->command(interpretKeyEvent(event));
+
+    if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+        // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
+        // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or if not to let a CHAR event be generated
+        // (e.g. Tab that inserts a Tab character, or Enter).
+        return !command.isTextInsertion() && command.execute(event);
+    }
+
+     if (command.execute(event))
+        return true;
+
+    // Don't insert null or control characters as they can result in unexpected behaviour
+    if (event->charCode() < ' ')
+        return false;
+
+    return frame->editor()->insertText(event->keyEvent()->text(), event);
+}
+
+const char* EditorClientWx::interpretKeyEvent(const KeyboardEvent* evt)
+{
+    ASSERT(evt->keyEvent()->type() == PlatformKeyboardEvent::RawKeyDown || evt->keyEvent()->type() == PlatformKeyboardEvent::Char);
+
+    static HashMap<int, const char*>* keyDownCommandsMap = 0;
+    static HashMap<int, const char*>* keyPressCommandsMap = 0;
+
+    if (!keyDownCommandsMap) {
+        keyDownCommandsMap = new HashMap<int, const char*>;
+        keyPressCommandsMap = new HashMap<int, const char*>;
+
+        for (unsigned i = 0; i < WXSIZEOF(keyDownEntries); i++)
+            keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, keyDownEntries[i].name);
+
+        for (unsigned i = 0; i < WXSIZEOF(keyPressEntries); i++)
+            keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode, keyPressEntries[i].name);
+    }
+
+    unsigned modifiers = 0;
+    if (evt->shiftKey())
+        modifiers |= ShiftKey;
+    if (evt->altKey())
+        modifiers |= AltKey;
+    if (evt->ctrlKey())
+        modifiers |= CtrlKey;
+
+    if (evt->keyEvent()->type() == PlatformKeyboardEvent::RawKeyDown) {
+        int mapKey = modifiers << 16 | evt->keyCode();
+        return mapKey ? keyDownCommandsMap->get(mapKey) : 0;
+    }
+
+    int mapKey = modifiers << 16 | evt->charCode();
+    return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
+}
+
+
 void EditorClientWx::handleInputMethodKeydown(KeyboardEvent* event)
 {
 // NOTE: we don't currently need to handle this. When key events occur,
@@ -295,63 +438,8 @@ void EditorClientWx::handleInputMethodKeydown(KeyboardEvent* event)
 
 void EditorClientWx::handleKeyboardEvent(KeyboardEvent* event)
 {
-    Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    if (!frame)
-        return;
-
-    const PlatformKeyboardEvent* kevent = event->keyEvent();
-    if (kevent->type() != PlatformKeyboardEvent::KeyUp) {
-        Node* start = frame->selection()->start().node();
-        if (!start || !start->isContentEditable())
-            return; 
-        
-        if (kevent->type() == PlatformKeyboardEvent::Char && !kevent->ctrlKey() && !kevent->altKey()) {
-            switch (kevent->windowsVirtualKeyCode()) {
-                // we handled these on key down, ignore them for char events
-                case VK_BACK:
-                case VK_DELETE:
-                case VK_LEFT:
-                case VK_RIGHT:
-                case VK_UP:
-                case VK_DOWN:
-                case VK_RETURN:
-                    break;
-                default:
-                    frame->editor()->insertText(kevent->text(), event);
-            }
-            event->setDefaultHandled();
-            return; 
-        }
-        
-        switch (kevent->windowsVirtualKeyCode()) {
-            case VK_BACK:
-                frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
-                                                     CharacterGranularity, false, true);
-                break;
-            case VK_DELETE:
-                frame->editor()->deleteWithDirection(SelectionController::FORWARD,
-                                                     CharacterGranularity, false, true);
-                break;
-            case VK_LEFT:
-                frame->editor()->command("MoveLeft").execute();
-                break;
-            case VK_RIGHT:
-                frame->editor()->command("MoveRight").execute();
-                break;
-            case VK_UP:
-                frame->editor()->command("MoveUp").execute();
-                break;
-            case VK_DOWN:
-                frame->editor()->command("MoveDown").execute();
-                break;
-            case VK_RETURN:
-                frame->editor()->command("InsertLineBreak").execute();
-            default:
-                break;
-        }
-            
+    if (handleEditingKeyboardEvent(event))
         event->setDefaultHandled();
-    }
 }
 
 void EditorClientWx::textFieldDidBeginEditing(Element*)
index 0f98167..79b0516 100644 (file)
@@ -87,6 +87,8 @@ public:
     virtual void undo();
     virtual void redo();
     
+    virtual const char* interpretKeyEvent(const KeyboardEvent*);
+    virtual bool handleEditingKeyboardEvent(KeyboardEvent*);
     virtual void handleKeyboardEvent(KeyboardEvent*);
     virtual void handleInputMethodKeydown(KeyboardEvent*);
     
index 32c96dc..6a925f3 100644 (file)
@@ -46,6 +46,7 @@
 #include "PlatformWheelEvent.h"
 #include "RenderObject.h"
 #include "RenderView.h"
+#include "Scrollbar.h"
 #include "SelectionController.h"
 #include "Settings.h"
 #include "SubstituteData.h"
@@ -638,7 +639,7 @@ void wxWebView::Copy()
 bool wxWebView::CanCut()
 {
     if (m_mainFrame)
-        m_mainFrame->CanCut();
+        return m_mainFrame->CanCut();
 
     return false;
 }
@@ -652,7 +653,7 @@ void wxWebView::Cut()
 bool wxWebView::CanPaste()
 {
     if (m_mainFrame)
-        m_mainFrame->CanPaste();
+        return m_mainFrame->CanPaste();
 
     return false;
 }
@@ -661,7 +662,6 @@ void wxWebView::Paste()
 {
     if (m_mainFrame)
         m_mainFrame->Paste();
-
 }
 
 void wxWebView::OnKeyEvents(wxKeyEvent& event)
@@ -669,40 +669,137 @@ void wxWebView::OnKeyEvents(wxKeyEvent& event)
     WebCore::Frame* frame = 0;
     if (m_mainFrame)
         frame = m_mainFrame->GetFrame();
-        
-    if (frame && frame->view()) {
-        // WebCore doesn't handle these events itself, so we need to do
-        // it and not send the event down or else CTRL+C will erase the text
-        // and replace it with c.
-        if (event.CmdDown() && event.GetEventType() == wxEVT_KEY_UP) {
-            if (event.GetKeyCode() == static_cast<int>('C'))
+
+    if (!(frame && frame->view()))
+        return;
+
+    if (event.GetKeyCode() == WXK_CAPITAL)
+        frame->eventHandler()->capsLockStateMayHaveChanged();
+
+    WebCore::PlatformKeyboardEvent wkEvent(event);
+
+    if (frame->eventHandler()->keyEvent(wkEvent))
+        return;
+
+    //Some things WebKit won't do for us... Copy/Cut/Paste and KB scrolling
+    if (event.GetEventType() == wxEVT_KEY_DOWN) {
+        switch (event.GetKeyCode()) {
+        case 67: //"C"
+            if (CanCopy() && event.GetModifiers() == wxMOD_CMD) {
                 Copy();
-            else if (event.GetKeyCode() == static_cast<int>('X'))
+                return;
+            }
+            break;
+        case 86: //"V"
+            if (CanPaste() && event.GetModifiers() == wxMOD_CMD) {
+                Paste();
+                return;
+            }
+            break;
+        case 88: //"X"
+            if (CanCut() && event.GetModifiers() == wxMOD_CMD) {
                 Cut();
-            else if (event.GetKeyCode() == static_cast<int>('V'))
+                return;
+            }
+            break;
+        case WXK_INSERT:
+            if (CanCopy() && event.GetModifiers() == wxMOD_CMD) {
+                Copy();
+                return;
+            }
+            if (CanPaste() && event.GetModifiers() == wxMOD_SHIFT) {
                 Paste();
-            else if (event.GetKeyCode() == static_cast<int>('Z')) {
-                if (event.ShiftDown()) {
-                    if (m_mainFrame->CanRedo())
-                        m_mainFrame->Redo();
-                }
-                else {
-                    if (m_mainFrame->CanUndo())
-                        m_mainFrame->Undo();
-                }
+                return;
             }
-        } else {    
-            WebCore::PlatformKeyboardEvent wkEvent(event);
-            if (wkEvent.type() == WebCore::PlatformKeyboardEvent::Char && wkEvent.altKey())
-                frame->eventHandler()->handleAccessKey(wkEvent);
-            else
-                frame->eventHandler()->keyEvent(wkEvent);
+            return; //Insert shall not become a char
+        case WXK_DELETE:
+            if (CanCut() && event.GetModifiers() == wxMOD_SHIFT) {
+                Cut();
+                return;
+            }
+            break;
+        case WXK_LEFT:
+        case WXK_NUMPAD_LEFT:
+            frame->view()->scrollBy(WebCore::IntSize(-WebCore::cScrollbarPixelsPerLineStep, 0));
+            return;
+        case WXK_UP:
+        case WXK_NUMPAD_UP:
+            frame->view()->scrollBy(WebCore::IntSize(0, -WebCore::cScrollbarPixelsPerLineStep));
+            return;
+        case WXK_RIGHT:
+        case WXK_NUMPAD_RIGHT:
+            frame->view()->scrollBy(WebCore::IntSize(WebCore::cScrollbarPixelsPerLineStep, 0));
+            return;
+        case WXK_DOWN:
+        case WXK_NUMPAD_DOWN:
+            frame->view()->scrollBy(WebCore::IntSize(0, WebCore::cScrollbarPixelsPerLineStep));
+            return;
+        case WXK_END:
+        case WXK_NUMPAD_END:
+            frame->view()->setScrollPosition(WebCore::IntPoint(frame->view()->scrollX(), frame->view()->maximumScrollPosition().y()));
+            return;
+        case WXK_HOME:
+        case WXK_NUMPAD_HOME:
+            frame->view()->setScrollPosition(WebCore::IntPoint(frame->view()->scrollX(), 0));
+            return;
+        case WXK_PAGEUP:
+        case WXK_NUMPAD_PAGEUP:
+            frame->view()->scrollBy(WebCore::IntSize(0, -frame->view()->visibleHeight() + WebCore::cAmountToKeepWhenPaging));
+            return;
+        case WXK_PAGEDOWN:
+        case WXK_NUMPAD_PAGEDOWN:
+            frame->view()->scrollBy(WebCore::IntSize(0, frame->view()->visibleHeight() - WebCore::cAmountToKeepWhenPaging));
+            return;
+        //These we don't want turning into char events, stuff 'em
+        case WXK_ESCAPE:
+        case WXK_LBUTTON:
+        case WXK_RBUTTON:
+        case WXK_CANCEL:
+        case WXK_MENU:
+        case WXK_MBUTTON:
+        case WXK_CLEAR:
+        case WXK_PAUSE:
+        case WXK_SELECT:
+        case WXK_PRINT:
+        case WXK_EXECUTE:
+        case WXK_SNAPSHOT:
+        case WXK_HELP:
+        case WXK_F1:
+        case WXK_F2:
+        case WXK_F3:
+        case WXK_F4:
+        case WXK_F5:
+        case WXK_F6:
+        case WXK_F7:
+        case WXK_F8:
+        case WXK_F9:
+        case WXK_F10:
+        case WXK_F11:
+        case WXK_F12:
+        case WXK_F13:
+        case WXK_F14:
+        case WXK_F15:
+        case WXK_F16:
+        case WXK_F17:
+        case WXK_F18:
+        case WXK_F19:
+        case WXK_F20:
+        case WXK_F21:
+        case WXK_F22:
+        case WXK_F23:
+        case WXK_F24:
+        case WXK_NUMPAD_F1:
+        case WXK_NUMPAD_F2:
+        case WXK_NUMPAD_F3:
+        case WXK_NUMPAD_F4:
+        //When numlock is off Numpad 5 becomes BEGIN, or HOME on Char
+        case WXK_NUMPAD_BEGIN:
+        case WXK_NUMPAD_INSERT:
+            return;
         }
     }
-    
-    // make sure we get the character event.
-    if (event.GetEventType() != wxEVT_CHAR)
-        event.Skip();
+
+    event.Skip();
 }
 
 void wxWebView::OnSetFocus(wxFocusEvent& event)