ant-design/components/input-number/demo/keyboard.md
2022-05-21 22:14:15 +08:00

672 B

order title
5
zh-CN en-US
键盘行为 Keyboard

zh-CN

使用 keyboard 属性可以控制键盘行为。

en-US

Control keyboard behavior by keyboard.

import { Checkbox, InputNumber, Space } from 'antd';
import React, { useState } from 'react';

const App: React.FC = () => {
  const [keyboard, setKeyboard] = useState(true);

  return (
    <Space>
      <InputNumber min={1} max={10} keyboard={keyboard} defaultValue={3} />
      <Checkbox
        onChange={() => {
          setKeyboard(!keyboard);
        }}
        checked={keyboard}
      >
        Toggle keyboard
      </Checkbox>
    </Space>
  );
};

export default App;