Skip to content

[과제번역] Part2. 3.7 Keyboard: keydown and keyup 과제 번역 #1121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

We should use two handlers: `document.onkeydown` and `document.onkeyup`.
우리는 `document.onkeydown` `document.onkeyup`의 두 가지 핸들러를 사용해야 합니다.

Let's create a set `pressed = new Set()` to keep currently pressed keys.
현재 누른 키를 유지할 수 있도록 `pressed = new Set()` 세트를 만듭니다.

The first handler adds to it, while the second one removes from it. Every time on `keydown` we check if we have enough keys pressed, and run the function if it is so.
첫 번째 핸들러가 추가되고 두 번째 핸들러는 제거됩니다. `keydown`을 할 때마다 충분한 키를 눌렀는지 확인하고, 그 경우에 함수를 실행합니다.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 5

---

# Extended hotkeys
# 확장 단축키

Create a function `runOnKeys(func, code1, code2, ... code_n)` that runs `func` on simultaneous pressing of keys with codes `code1`, `code2`, ..., `code_n`.
함수 `runOnKeys(func, code1, code2, ... code_n)`를 만듭니다. 함수 runOnKeys는 `code1`, `code2`, ..., `code_n`이 있는 키를 동시에 누를 때 `func`를 실행하는 함수입니다.

For instance, the code below shows `alert` when `"Q"` and `"W"` are pressed together (in any language, with or without CapsLock)
예를 들어 아래 코드는 `"Q"` `"W"` 를 함께 누르면 `alert` 창이 표시됩니다(CapsLock 사용 여부에 관계없이 모든 언어에서 표시됨).

```js no-beautify
runOnKeys(
Expand Down