public static bool GetKeyDown(KCode key) { if (KeyRepeatRate.softwareEmulatedPress == key) { return(true); } #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER if (TryGetKeyButton(key, out ButtonControl keyControl) || TryGetMouseButton(key, out keyControl)) { //if (keyControl.wasPressedThisFrame) Debug.Log("checking "+key+" "+keyControl.wasPressedThisFrame+" "+keyControl.name+" "+keyControl.displayName+" "+keyControl.shortDisplayName); return(keyControl.wasPressedThisFrame); } #else if (IsOldKeyCode(key)) { return(UnityEngine.Input.GetKeyDown((KeyCode)key)); } #endif KState ks; _pressState.TryGetValue(key, out ks); if (ks == KState.KeyHeld || ks == KState.KeyUp) { return(false); } bool pressed = GetKey_internal(key); if (pressed && ks == KState.KeyReleased) { _pressState[key] = KState.KeyDown; } return(pressed); }
/// <summary> /// 键盘输入 /// </summary> /// <param name="key"></param> public void onInput(KCode key) { if (key == KCode.Escape) { gameObject.SetActive(false); m_isShow = false; } else if (key == KCode.LeftArrow) { if (m_progressBar.value > 0) { //TODO } } else if (key == KCode.RightArrow) { //TODO } else if (key == KCode.UpArrow) { //TODO } else if (key == KCode.DownArrow) { //TODO } }
/// <summary> /// 键盘输入 /// </summary> /// <param name="key"></param> public void onInput(KCode key) { if( key == KCode.Escape ) { gameObject.SetActive(false); m_isShow = false; } else if( key == KCode.LeftArrow ) { if( m_progressBar.value > 0 ) { //TODO } } else if( key == KCode.RightArrow ) { //TODO } else if( key == KCode.UpArrow ) { //TODO } else if( key == KCode.DownArrow ) { //TODO } }
public bool AxisUpdate(AxisControl control, KCode kCode) { if (AppInput.IsQuitting) { return(true); } bool isRelease = control.IsPressed(); int k = (int)kCode; if (isRelease) { if (OnRelease.TryGetValue(kCode, out SpecificControlHandler handler)) { handler.Invoke(kCode, control); } activeControl.Remove(kCode); } else { if (OnPressed.TryGetValue(kCode, out SpecificControlHandler handler)) { handler.Invoke(kCode, control); } activeControl[kCode] = control; } return(true); }
public static bool GetKeyUp(KCode key) { #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER if (TryGetKeyButton(key, out ButtonControl keyControl) || TryGetMouseButton(key, out keyControl)) { return(keyControl.wasReleasedThisFrame); } #else if (IsOldKeyCode(key)) { return(UnityEngine.Input.GetKeyUp((KeyCode)key)); } #endif KState ks; _pressState.TryGetValue(key, out ks); if (ks == KState.KeyReleased || ks == KState.KeyDown) { return(false); } bool pressed = GetKey_internal(key); if (!pressed && ks == KState.KeyHeld) { _pressState[key] = KState.KeyReleased; } return(!pressed); }
private static bool GetKey_internal_legacy(KCode key) { switch (key) { case KCode.NoShift: return(!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)); case KCode.NoCtrl: return(!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl)); case KCode.NoAlt: return(!Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt)); case KCode.AnyAlt: return(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)); case KCode.AnyCtrl: return(Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)); case KCode.AnyShift: return(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)); case KCode.MouseWheelUp: return(Input.GetAxis("Mouse ScrollWheel") > 0); case KCode.MouseWheelDown: return(Input.GetAxis("Mouse ScrollWheel") < 0); case KCode.MouseXUp: return(Input.GetAxis("Mouse X") > 0); case KCode.MouseXDown: return(Input.GetAxis("Mouse X") < 0); case KCode.MouseYUp: return(Input.GetAxis("Mouse Y") > 0); case KCode.MouseYDown: return(Input.GetAxis("Mouse Y") < 0); // default: throw new Exception($"can't handle {key}"); } return(false); }
public override void onInput(KCode key) { int newIndex = m_fileName.KeyInput(key, m_curIndex); if (newIndex >= 0) { m_curIndex = newIndex; } else { switch (key) { case KCode.Escape: m_stateMgr.GotoState(StateEnums.eStateList); return; case KCode.Return: CodeMgr.SharedInstance.SaveSourceCode(m_fileName.TEXT + ".BAS", m_stateMgr.CUR_SOURCE_CODE); m_stateMgr.GotoState(StateEnums.eStateList); return; default: break; } } refresh(); }
private static bool GetKey_internal_InputSystem(KCode key) { switch (key) { case KCode.NoShift: return(!Keyboard.current.leftShiftKey.isPressed && !Keyboard.current.rightShiftKey.isPressed); case KCode.NoAlt: return(!Keyboard.current.leftAltKey.isPressed && !Keyboard.current.rightAltKey.isPressed); case KCode.NoCtrl: return(!Keyboard.current.leftCtrlKey.isPressed && !Keyboard.current.rightCtrlKey.isPressed); case KCode.AnyShift: return(Keyboard.current.leftShiftKey.isPressed || Keyboard.current.rightShiftKey.isPressed);; case KCode.AnyAlt: return(Keyboard.current.leftAltKey.isPressed || Keyboard.current.rightAltKey.isPressed); case KCode.AnyCtrl: return(Keyboard.current.leftCtrlKey.isPressed || Keyboard.current.rightCtrlKey.isPressed); case KCode.MouseWheelUp: return(Mouse.current.scroll.y.ReadValue() > 0); case KCode.MouseWheelDown: return(Mouse.current.scroll.y.ReadValue() < 0); case KCode.MouseXUp: return(Mouse.current.delta.x.ReadValue() > 0); case KCode.MouseXDown: return(Mouse.current.delta.x.ReadValue() < 0); case KCode.MouseYUp: return(Mouse.current.delta.y.ReadValue() > 0); case KCode.MouseYDown: return(Mouse.current.delta.y.ReadValue() < 0); } return(false); }
private static bool GetKey_internal(KCode key) { bool v = false; switch (key) { case KCode.AnyAlt: v = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt); break; case KCode.AnyControl: v = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); break; case KCode.AnyShift: v = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); break; case KCode.MouseWheelUp: v = Input.GetAxis("Mouse ScrollWheel") > 0; break; case KCode.MouseWheelDown: v = Input.GetAxis("Mouse ScrollWheel") < 0; break; case KCode.MouseXUp: v = Input.GetAxis("Mouse X") > 0; break; case KCode.MouseXDown: v = Input.GetAxis("Mouse X") < 0; break; case KCode.MouseYUp: v = Input.GetAxis("Mouse Y") > 0; break; case KCode.MouseYDown: v = Input.GetAxis("Mouse Y") < 0; break; // default: throw new Exception($"can't handle {key}"); } return(v); }
public static void LoadSettingsKeys() { if (GameLogic.isLoad) { return; } InputData inputData = new InputData(); string _keysPath = GameLogic.KeysPath; if (!File.Exists(_keysPath)) { inputData.SetDefault(); Utility.SerializeData(_keysPath, inputData); } inputData = (InputData)Utility.DeserializeData(_keysPath, typeof(InputData)); int i; for (i = 0; i < inputData.InputList.Count; i++) { SettingsData data = inputData.InputList[i]; foreach (KeyCode KCode in Enum.GetValues(typeof(KeyCode))) { if (KCode.ToString() == data.Value) { AddNewKey(data.Key, KCode); } } } }
/// <summary> /// 键盘输入 /// </summary> /// <param name="key"></param> public void onInput( KCode key ) { switch(key) { case KCode.LeftArrow: focosOn(true); break; case KCode.RightArrow: focosOn(false); break; case KCode.Y: case KCode.y_l: focosOn(true); confirmSelect(); break; case KCode.N: case KCode.n_l: focosOn(false); confirmSelect(); break; case KCode.Return: confirmSelect(); break; default: break; } }
/// <summary> /// 键盘输入 /// </summary> /// <param name="key"></param> public void onInput(KCode key) { switch (key) { case KCode.LeftArrow: focosOn(true); break; case KCode.RightArrow: focosOn(false); break; case KCode.Y: case KCode.y_l: focosOn(true); confirmSelect(); break; case KCode.N: case KCode.n_l: focosOn(false); confirmSelect(); break; case KCode.Return: confirmSelect(); break; default: break; } }
protected void onMoveCursor(KCode dir) { LineInfo line = m_buffer[m_curLine]; if (dir == KCode.UpArrow) { if (m_curIndex >= Defines.TEXT_AREA_WIDTH) { m_curIndex -= Defines.TEXT_AREA_WIDTH; } else if (m_curLine > 0) { if (line.LINE_NUM < 0) { m_stateMgr.NotifierInfo(Defines.INFO_LINE_NUM_ERR); } else { // 移至上一行 m_curLine--; m_curIndex = m_buffer[m_curLine].GetLastLineIndex(m_curIndex); } } } else if (dir == KCode.DownArrow) { if (m_curIndex + Defines.TEXT_AREA_WIDTH < line.LENGTH) { m_curIndex += Defines.TEXT_AREA_WIDTH; } else if (m_curLine < m_buffer.Count - 1) { if (line.LINE_NUM < 0) { m_stateMgr.NotifierInfo(Defines.INFO_LINE_NUM_ERR); } else { // 移至下一行 m_curLine++; m_curIndex = m_buffer[m_curLine].GetFirstLineIndex(m_curIndex % Defines.TEXT_AREA_WIDTH); } } } else if (dir == KCode.LeftArrow) { if (m_curIndex > 0) { m_curIndex--; } } else if (dir == KCode.RightArrow) { if (m_curIndex < line.LENGTH) { m_curIndex++; } } }
private static bool GetKey_internal(KCode key) { #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER return(GetKey_internal_InputSystem(key)); #else return(GetKey_internal_legacy(key)); #endif }
/// <summary> /// key input /// </summary> /// <param name="key"></param> /// <param name="curIndex"></param> /// <returns></returns> public int KeyInput(KCode key, int curIndex) { // move the cursor int newIndex = curIndex; if (key == KCode.LeftArrow) { if (curIndex > 0) { newIndex = curIndex - 1; } } else if (key == KCode.RightArrow) { if (curIndex < LENGTH) { newIndex = curIndex + 1; } } else if (key == KCode.Delete) { if (LENGTH > 0) { if (curIndex < LENGTH) { Remove(curIndex); } else { Remove(curIndex - 1); newIndex = curIndex - 1; } } else { newIndex = -1; } } else { int chr = (int)key; // don't process this key input if (chr < 0 || chr >= 127 || key == KCode.Return || key == KCode.Escape) { newIndex = -1; } else { SetChar(curIndex, (char)chr); newIndex = curIndex + 1; } } refreshLineNum(); return(newIndex); }
public override void onInput(KCode key) { if( key == KCode.Escape ) { m_stateMgr.GotoState(StateEnums.eStateList); return; } switch(m_status) { case STATUS_INKEY: m_emuAPI.AppendInkey(key); m_inkeyCount--; // 输入完毕退出 if (m_inkeyCount <= 0) m_status = STATUS_RUNNING; break; case STATUS_INPUT: if( key == KCode.Return ) { // 一个输入完毕 m_emuAPI.AppendInput(m_inputBuff.ToString()); m_inputCount--; // 显示换行 m_stateMgr.m_textDisplay.DrawText(m_stateMgr.m_textDisplay.CURSOR_X, m_stateMgr.m_textDisplay.CURSOR_Y, "\n"); m_stateMgr.m_textDisplay.SetCursor(0, 0); // 全部输入完毕 if (m_inputCount <= 0) m_status = STATUS_RUNNING; else m_inputBuff = new StringBuilder(); } else if( key == KCode.Backspace ) { // 删除一个字符 if( m_inputCount > 0 ) { //TODO m_inputCount--; } } else { if (key < KCode.Delete) { m_inputBuff.Append((char)key); // 显示该字符 m_stateMgr.m_textDisplay.DrawText(m_stateMgr.m_textDisplay.CURSOR_X, m_stateMgr.m_textDisplay.CURSOR_Y, ((char)key).ToString()); m_stateMgr.m_textDisplay.SetCursor(0, 0); } } break; default: break; } }
public void Init() { key = key.Normalized(); if (modifiers == null) { return; } //for (int i = 0; i < modifiers.Length; ++i) { modifiers[i] = modifiers[i].Init(); } }
public override void onInput(KCode key) { switch (key) { case KCode.UpArrow: if (m_curItemIdx > 0) { refreshList(m_curItemIdx - 1); } break; case KCode.DownArrow: if (m_curItemIdx < m_basList.Count - 1) { refreshList(m_curItemIdx + 1); } break; case KCode.Return: executeItem(); break; case KCode.F2: // 弹出确认删除的提示 m_stateMgr.ShowMessageBox("Delete file", () => { deleteCurrentFile(); }, () => { refreshList(m_curItemIdx); }); break; case KCode.F1: // 弹出确认创建的提示 m_stateMgr.ShowMessageBox("Create file", () => { createNewFile(); }, () => { refreshList(m_curItemIdx); }); break; case KCode.F4: editFile(); break; default: break; } }
public static void GetUp(List <KCode> out_keys) { for (int i = 0; i < (int)KCode.LAST; ++i) { KCode key = (KCode)i; if (IsUp(key)) { out_keys.Add(key); } } }
private static bool TryGetKeyButton(KCode key, out ButtonControl buttonControl) { if (!KCodeExtensionUnity.kCodeToInputSystem.TryGetValue(key, out UnityEngine.InputSystem.Key k)) { buttonControl = null; return(false); } buttonControl = Keyboard.current[k]; return(true); }
public void Update(KCode specificKey, Func <KBind, bool> additionalFilter = null) { if (!bindingsByKey.TryGetValue(specificKey, out List <KBindTrigger> kBindListing)) { return; } for (int i = 0; i < kBindListing.Count; ++i) { KeyCheck(kBindListing[i].kBind, triggerList, additionalFilter); } }
public void AppendInkey(KCode kcode) { if (kcode < KCode.Delete) { m_inkeyBuff.Add((char)kcode); } else { m_inkeyBuff.Add(' '); } }
public static KState GetState(this KCode kCode) { // prevent two-finger-right-click on touch screens, it messes with other right-click behaviour if (kCode == KCode.Mouse1 && UnityEngine.Input.touches != null && UnityEngine.Input.touches.Length >= 2) { return(KState.KeyReleased); } return(AppInput.GetKeyDown(kCode) ? KState.KeyDown : AppInput.GetKeyUp(kCode) ? KState.KeyUp : AppInput.GetKey(kCode) ? KState.KeyHeld : KState.KeyReleased); }
private void Update() { if (_isClick) { foreach (KeyCode KCode in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(KCode)) { _text.text = KCode.ToString(); InputManager.UpdateKey(this.name, KCode); _isClick = false; } } } }
/// <summary> /// 字符输入 /// </summary> /// <param name="code"></param> public void onInputKey(KCode key) { if (key >= KCode.Space && key < KCode.Delete) // 可输入字符 { if (m_insertMode) { m_buffer[m_curLine].InsChar(m_curIndex, (char)key); } else { m_buffer[m_curLine].SetChar(m_curIndex, (char)key); } m_curIndex++; } }
private static bool TryGetMouseButton(KCode key, out ButtonControl buttonControl) { switch (key) { case KCode.Mouse0: buttonControl = Mouse.current.leftButton; return(true); case KCode.Mouse1: buttonControl = Mouse.current.rightButton; return(true); case KCode.Mouse2: buttonControl = Mouse.current.middleButton; return(true); case KCode.Mouse3: buttonControl = Mouse.current.forwardButton; return(true); // TODO testme case KCode.Mouse4: buttonControl = Mouse.current.backButton; return(true); // TODO testme } buttonControl = null; return(false); }
/// <summary> /// key input /// </summary> /// <param name="key"></param> public override void onInput(KCode key) { switch (key) { case KCode.Home: onClearAll(); break; case KCode.Return: onReturn(); break; case KCode.UpArrow: case KCode.DownArrow: case KCode.LeftArrow: case KCode.RightArrow: onMoveCursor(key); break; case KCode.Delete: case KCode.Backspace: onDel(); break; case KCode.Escape: exportCode(); m_stateMgr.GotoState(StateEnums.eStateSaver); return; case KCode.F1: m_insertMode = !m_insertMode; // 切换插入/覆盖模式 m_stateMgr.m_textDisplay.UNDER_CURSOR = m_insertMode; break; case KCode.CapsLock: m_stateMgr.m_keyboard.SetCaps(!m_stateMgr.m_keyboard.CAPS); // 切换字母大小写 break; default: onInputKey(key); break; } refresh(); }
/// <summary> /// an abstraction layer to catch inconsistencies with presses and releases. ignores bad presses and bad releases /// </summary> /// <param name="control"></param> /// <param name="kCode"></param> /// <returns>true if there are no errors</returns> public bool PressAndReleaseUpdate(ButtonControl control, KCode kCode) { if (AppInput.IsQuitting) { return(true); } bool isRelease = control.IsPressed(); int k = (int)kCode; if (isRelease) { if (!activeControl.ContainsKey(kCode)) { Debug.Log("double release " + control + "? " + kCode); } else { //Debug.Log("good release"); if (OnRelease.TryGetValue(kCode, out SpecificControlHandler handler)) { handler.Invoke(kCode, control); } activeControl.Remove(kCode); OnReleaseAny?.Invoke(kCode, control); } } else { if (activeControl.ContainsKey(kCode)) { Debug.Log("double press " + control + "? " + kCode); } else { //Debug.Log("good press"); if (OnPressed.TryGetValue(kCode, out SpecificControlHandler handler)) { handler.Invoke(kCode, control); } activeControl[kCode] = control; OnPressedAny?.Invoke(kCode, control); } } return(true); }
public bool AddModifier(KCode kCode) { Modifier mod = new Modifier(kCode); if (HasModifier(mod)) { return(false); } List <Modifier> mods = new List <Modifier>(); if (modifiers != null) { mods.AddRange(modifiers); } mods.Add(mod); mods.Sort(); modifiers = mods.ToArray(); return(true); }
public static bool GetKey(KCode key) { bool pressed; #if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER if (TryGetKeyButton(key, out ButtonControl keyControl) || TryGetMouseButton(key, out keyControl)) { pressed = keyControl.isPressed; if (pressed) { heldKeys.Add(key); } return(pressed); } #else if (IsOldKeyCode(key)) { pressed = UnityEngine.Input.GetKey((KeyCode)key); if (pressed && (key < KCode.NoShift || key > KCode.NoAlt)) { heldKeys.Add(key); } return(pressed); } #endif pressed = GetKey_internal(key); if (pressed && (key < KCode.NoShift || key > KCode.NoAlt)) { heldKeys.Add(key); } KState ks; _pressState.TryGetValue(key, out ks); if (pressed && ks == KState.KeyReleased) { _pressState[key] = KState.KeyDown; } if (!pressed && ks == KState.KeyHeld) { _pressState[key] = KState.KeyUp; } return(pressed); }
public static bool GetKey(KCode key) { if (IsOldKeyCode(key)) { return(UnityEngine.Input.GetKey((KeyCode)key)); } bool pressed = GetKey_internal(key); KState ks; _pressState.TryGetValue(key, out ks); if (pressed && ks == KState.KeyReleased) { _pressState[key] = KState.KeyDown; } if (!pressed && ks == KState.KeyHeld) { _pressState[key] = KState.KeyUp; } return(pressed); }
/// <summary> /// input /// </summary> /// <param name="key"></param> public void Input( KCode key ) { if (m_infoNotifier.IS_SHOW) return; if ( m_msgBox.IS_SHOW ) { m_msgBox.onInput(key); } else if( m_helpBoard.IS_SHOW ) { m_helpBoard.onInput(key); } else if( key == KCode.F3 ) { ShowHelp(); } else { m_curState.onInput(key); } }
// Update is called once per frame void Update() { if (!Input.anyKeyDown) { return; } for (KCode k = KCode.None; k <= KCode.CapsLock; k++) { if (Input.GetKeyDown((KeyCode)k)) { // 小写字母转换成大写字母 if ((int)k >= 97 && (int)k <= 122) { k -= 32; } SendKey(k); break; } } }
public void Update() { if (softwareEmulatedPress != KCode.None) { softwareEmulatedPress = KCode.None; } if (heldKeys.Count > 0) { KCode thisHeldKey = KCode.None; foreach (KCode k in heldKeys) { thisHeldKey = k; break; } heldKeys.Clear(); if (thisHeldKey != KCode.None && (thisHeldKey < KCode.Mouse0 || thisHeldKey > KCode.Mouse6)) { ulong now = Proc.Now; if (thisHeldKey == lastHeldKey && lastKeyHeldTime != 0) { heldDuration += now - lastKeyHeldTime; if (heldDuration > initialDelay) { heldDuration -= repeatDelay; softwareEmulatedPress = thisHeldKey; } } lastKeyHeldTime = now; lastHeldKey = thisHeldKey; } } else { lastHeldKey = KCode.None; lastKeyHeldTime = 0; heldDuration = 0; } }
/// <summary> /// 设置键 /// </summary> /// <param name="kcode"></param> public void SetKeyCode( KCode kcode ) { m_key = kcode; m_txtKeyDisplay.text = ((char)m_key).ToString(); }
public virtual void onInput( KCode key ) {}
protected void onMoveCursor( KCode dir ) { LineInfo line = m_buffer[m_curLine]; if( dir == KCode.UpArrow ) { if (m_curIndex >= Defines.TEXT_AREA_WIDTH) { m_curIndex -= Defines.TEXT_AREA_WIDTH; } else if(m_curLine > 0) { if (line.LINE_NUM < 0) { m_stateMgr.NotifierInfo(Defines.INFO_LINE_NUM_ERR); } else { // 移至上一行 m_curLine--; m_curIndex = m_buffer[m_curLine].GetLastLineIndex(m_curIndex); } } } else if( dir == KCode.DownArrow ) { if (m_curIndex + Defines.TEXT_AREA_WIDTH < line.LENGTH) { m_curIndex += Defines.TEXT_AREA_WIDTH; } else if (m_curLine < m_buffer.Count - 1) { if (line.LINE_NUM < 0) { m_stateMgr.NotifierInfo(Defines.INFO_LINE_NUM_ERR); } else { // 移至下一行 m_curLine++; m_curIndex = m_buffer[m_curLine].GetFirstLineIndex(m_curIndex % Defines.TEXT_AREA_WIDTH); } } } else if( dir == KCode.LeftArrow ) { if (m_curIndex > 0) m_curIndex--; } else if( dir == KCode.RightArrow ) { if (m_curIndex < line.LENGTH) m_curIndex++; } }
/// <summary> /// 字符输入 /// </summary> /// <param name="code"></param> public void onInputKey( KCode key ) { if (key >= KCode.Space && key < KCode.Delete) // 可输入字符 { if (m_insertMode) m_buffer[m_curLine].InsChar(m_curIndex, (char)key); else m_buffer[m_curLine].SetChar(m_curIndex, (char)key); m_curIndex++; } }
public void AppendInkey( KCode kcode ) { if (kcode < KCode.Delete) m_inkeyBuff.Add((char)kcode); else m_inkeyBuff.Add(' '); }
/// <summary> /// key input /// </summary> /// <param name="key"></param> /// <param name="curIndex"></param> /// <returns></returns> public int KeyInput( KCode key, int curIndex ) { // move the cursor int newIndex = curIndex; if (key == KCode.LeftArrow) { if (curIndex > 0) newIndex = curIndex - 1; } else if (key == KCode.RightArrow) { if (curIndex < LENGTH) newIndex = curIndex + 1; } else if( key == KCode.Delete ) { if( LENGTH > 0 ) { if (curIndex < LENGTH) { Remove(curIndex); } else { Remove(curIndex - 1); newIndex = curIndex - 1; } } else { newIndex = -1; } } else { int chr = (int)key; // don't process this key input if (chr < 0 || chr >= 127 || key == KCode.Return || key == KCode.Escape) { newIndex = -1; } else { SetChar(curIndex, (char)chr); newIndex = curIndex + 1; } } refreshLineNum(); return newIndex; }