2021-01-29 14:35:05 +08:00
|
|
|
---
|
|
|
|
order: 5
|
|
|
|
title:
|
|
|
|
zh-CN: 键盘行为
|
|
|
|
en-US: Keyboard
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
使用 `keyboard` 属性可以控制键盘行为。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Control keyboard behavior by `keyboard`.
|
|
|
|
|
2021-02-22 22:07:19 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Checkbox, InputNumber, Space } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React, { useState } from 'react';
|
2021-02-22 22:07:19 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [keyboard, setKeyboard] = useState(true);
|
2021-02-22 22:07:19 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Space>
|
|
|
|
<InputNumber min={1} max={10} keyboard={keyboard} defaultValue={3} />
|
|
|
|
<Checkbox
|
|
|
|
onChange={() => {
|
|
|
|
setKeyboard(!keyboard);
|
|
|
|
}}
|
|
|
|
checked={keyboard}
|
|
|
|
>
|
|
|
|
Toggle keyboard
|
|
|
|
</Checkbox>
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
};
|
2021-01-29 14:35:05 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2021-01-29 14:35:05 +08:00
|
|
|
```
|