diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 83f308b26fd..f7bbbb39a2b 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -186,6 +186,9 @@ pub enum Key { RightAlt, RightSuper, Menu, + + NavigateBackward, + NavigateForward, } bitflags! { diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 9feb08b7674..8075a18433a 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -319,6 +319,8 @@ pub fn key_value(key: Key, mods: KeyModifiers) -> &'static str { Key::RightAlt => "Alt", Key::RightSuper => "Super", Key::Menu => "ContextMenu", + Key::NavigateForward => "BrowserForward", + Key::NavigateBackward => "BrowserBack", } } @@ -489,6 +491,8 @@ fn key_from_string(key_string: &str, location: u32) -> Option { "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt), "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightSuper), "ContextMenu" => Some(Key::Menu), + "BrowserForward" => Some(Key::NavigateForward), + "BrowserBack" => Some(Key::NavigateBackward), _ => None } } @@ -614,6 +618,9 @@ fn code_value(key: Key) -> &'static str { Key::LeftAlt | Key::RightAlt => "Alt", Key::LeftSuper | Key::RightSuper => "Super", Key::Menu => "Menu", + + Key::NavigateForward => "BrowserForward", + Key::NavigateBackward => "BrowserBackward", } } diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 22633931de1..5cebe5cc724 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -498,6 +498,8 @@ impl Window { VirtualKeyCode::Tab => Ok(Key::Tab), VirtualKeyCode::Subtract => Ok(Key::Minus), + VirtualKeyCode::NavigateBackward => Ok(Key::NavigateBackward), + VirtualKeyCode::NavigateForward => Ok(Key::NavigateForward), _ => Err(()), } } @@ -731,6 +733,12 @@ impl WindowMethods for Window { (NONE, Key::Backspace) => { self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); } + (SHIFT, Key::NavigateForward) => { + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward)); + } + (NONE, Key::NavigateBackward) => { + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); + } (NONE, Key::Escape) => { self.event_queue.borrow_mut().push(WindowEvent::Quit);