electron/shell/common/keyboard_util.h
Cheng Zhao 3cfe5c6a21
fix: keep shifted character in menu accelerator (#29202)
* fix: correctly handle shifted char in accelerator

* test: use actual accelerator of NSMenuItem

* chore: simplify KeyboardCodeFromStr

* chore: GetAcceleratorTextAt is testing only
2021-06-02 16:32:48 +09:00

27 lines
834 B
C++

// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_COMMON_KEYBOARD_UTIL_H_
#define SHELL_COMMON_KEYBOARD_UTIL_H_
#include <string>
#include "base/optional.h"
#include "ui/events/keycodes/keyboard_codes.h"
namespace electron {
// Return key code of the char, and also determine whether the SHIFT key is
// pressed.
ui::KeyboardCode KeyboardCodeFromCharCode(char16_t c, bool* shifted);
// Return key code of the |str|, if the original key is a shifted character,
// for example + and /, set it in |shifted_char|.
// pressed.
ui::KeyboardCode KeyboardCodeFromStr(const std::string& str,
base::Optional<char16_t>* shifted_char);
} // namespace electron
#endif // SHELL_COMMON_KEYBOARD_UTIL_H_