1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15export function GetHardKeyValue(keyCode, isShift) { 16 let keyList = { 17 2000: "0", 18 2001: "1", 19 2002: "2", 20 2003: "3", 21 2004: "4", 22 2005: "5", 23 2006: "6", 24 2007: "7", 25 2008: "8", 26 2009: "9", 27 2010: "*", 28 2011: "#", 29 2012: "KEYCODE_DPAD_UP", 30 2013: "KEYCODE_DPAD_DOWN", 31 2014: "KEYCODE_DPAD_LEFT", 32 2015: "KEYCODE_DPAD_RIGHT", 33 2016: "KEYCODE_DPAD_CENTER", 34 2017: "a", 35 2018: "b", 36 2019: "c", 37 2020: "d", 38 2021: "e", 39 2022: "f", 40 2023: "g", 41 2024: "h", 42 2025: "i", 43 2026: "j", 44 2027: "k", 45 2028: "l", 46 2029: "m", 47 2030: "n", 48 2031: "o", 49 2032: "p", 50 2033: "q", 51 2034: "r", 52 2035: "s", 53 2036: "t", 54 2037: "u", 55 2038: "v", 56 2039: "w", 57 2040: "x", 58 2041: "y", 59 2042: "z", 60 2043: ",", 61 2044: ".", 62 2047: "KEYCODE_SHIFT_LEFT", 63 2048: "KEYCODE_SHIFT_RIGHT", 64 2050: " ", 65 2055: "KEYCODE_DEL", 66 2058: "=", 67 2071: "KEYCODE_FORWARD_DEL", 68 2064: "/", 69 2065: "@", 70 2066: "+", 71 2121: "(", 72 2122: ")", 73 }; 74 75 if (keyList.hasOwnProperty(keyCode)) { 76 let value = keyList[keyCode] 77 if (isShift && keyCode >= 2017 && keyCode <= 2042) { 78 return value.toUpperCase(); 79 } 80 return value; 81 } 82 if (keyCode == 2000) { 83 return "0" 84 } 85 return ""; 86} 87