Bridge Servo keyboard text input
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
use servo::Code;
|
||||
|
||||
pub(crate) fn keyboard_code_for_character(character: char) -> Code {
|
||||
match character {
|
||||
'a' | 'A' => Code::KeyA,
|
||||
'b' | 'B' => Code::KeyB,
|
||||
'c' | 'C' => Code::KeyC,
|
||||
'd' | 'D' => Code::KeyD,
|
||||
'e' | 'E' => Code::KeyE,
|
||||
'f' | 'F' => Code::KeyF,
|
||||
'g' | 'G' => Code::KeyG,
|
||||
'h' | 'H' => Code::KeyH,
|
||||
'i' | 'I' => Code::KeyI,
|
||||
'j' | 'J' => Code::KeyJ,
|
||||
'k' | 'K' => Code::KeyK,
|
||||
'l' | 'L' => Code::KeyL,
|
||||
'm' | 'M' => Code::KeyM,
|
||||
'n' | 'N' => Code::KeyN,
|
||||
'o' | 'O' => Code::KeyO,
|
||||
'p' | 'P' => Code::KeyP,
|
||||
'q' | 'Q' => Code::KeyQ,
|
||||
'r' | 'R' => Code::KeyR,
|
||||
's' | 'S' => Code::KeyS,
|
||||
't' | 'T' => Code::KeyT,
|
||||
'u' | 'U' => Code::KeyU,
|
||||
'v' | 'V' => Code::KeyV,
|
||||
'w' | 'W' => Code::KeyW,
|
||||
'x' | 'X' => Code::KeyX,
|
||||
'y' | 'Y' => Code::KeyY,
|
||||
'z' | 'Z' => Code::KeyZ,
|
||||
'0' => Code::Digit0,
|
||||
'1' => Code::Digit1,
|
||||
'2' => Code::Digit2,
|
||||
'3' => Code::Digit3,
|
||||
'4' => Code::Digit4,
|
||||
'5' => Code::Digit5,
|
||||
'6' => Code::Digit6,
|
||||
'7' => Code::Digit7,
|
||||
'8' => Code::Digit8,
|
||||
'9' => Code::Digit9,
|
||||
' ' => Code::Space,
|
||||
'-' | '_' => Code::Minus,
|
||||
'=' | '+' => Code::Equal,
|
||||
',' | '<' => Code::Comma,
|
||||
'.' | '>' => Code::Period,
|
||||
'/' | '?' => Code::Slash,
|
||||
';' | ':' => Code::Semicolon,
|
||||
'\'' | '"' => Code::Quote,
|
||||
'[' | '{' => Code::BracketLeft,
|
||||
']' | '}' => Code::BracketRight,
|
||||
'\\' | '|' => Code::Backslash,
|
||||
'`' | '~' => Code::Backquote,
|
||||
_ => Code::Unidentified,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user