Skip to content

Commit

Permalink
docs: update doc and demo
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Nov 14, 2023
1 parent 80e5a7c commit d4957cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/hooks/src/useKeyPress/demo/demo9.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { Switch } from 'antd';

export default () => {
const [counter, setCounter] = useState(0);
const [observe, { toggle }] = useBoolean();
const [observe, { toggle }] = useBoolean(true);

useKeyPress(
'uparrow',
'w',
() => {
setCounter((s) => s + 1);
setCounter((prev) => prev + 1);
},
{
observe,
Expand All @@ -21,7 +22,7 @@ export default () => {
Switch observe state  
<Switch checked={observe} onChange={toggle} />
</div>
<div>Press ArrowUp by key to increase when observe state is checked</div>
<div>Press [w] to increase when observe state is checked</div>
<div>
counter: <span style={{ color: '#f00' }}>{counter}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useKeyPress/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ useKeyPress(
| target | DOM element or ref | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| exactMatch | Exact match. If set `true`, the event will only be trigger when the keys match exactly. For example, pressing [shift + c] will not trigger [c] | `boolean` | `false` |
| useCapture | to block events bubbling | `boolean` | `false` |
| observe | to control the observe state. If set `true`, the event will be trigger when the element is in focus. | `boolean` | `true` |
| observe | to control the observe state. If set `false`, the callback will not be triggered. | `boolean` | `true` |

## Remarks

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useKeyPress/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ useKeyPress(
| target | DOM 节点或者 ref | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| exactMatch | 精确匹配。如果开启,则只有在按键完全匹配的情况下触发事件。比如按键 [shift + c] 不会触发 [c] | `boolean` | `false` |
| useCapture | 是否阻止事件冒泡 | `boolean` | `false` |
| observe | 控制监听状态 为 false 时不会触发任何事件 | `boolean` | `true` |
| observe | 是否开启监听状态,为 false 时不会触发回调函数 | `boolean` | `true` |

## Remarks

Expand Down

0 comments on commit d4957cc

Please sign in to comment.