• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { Callback } from './@ohos.base';
17
18/**
19 * The event of key input management module is configured to subscribe and unsubscribe system keys.
20 *
21 * @namespace inputConsumer
22 * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
23 * @systemapi hide for inner use
24 * @since 8
25 */
26declare namespace inputConsumer {
27  /**
28   * Defines event of key that user want to subscribe or unsubscribe.
29   *
30   * @interface KeyOptions
31   * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
32   * @systemapi hide for inner use
33   * @since 8
34   */
35  interface KeyOptions {
36    /**
37     * The pre-keys that want to subscribe or unsubscribe.
38     *
39     * @type { Array<number> }
40     * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
41     * @systemapi hide for inner use
42     * @since 8
43     */
44    preKeys: Array<number>;
45
46    /**
47     * The post position key that want to subscribe or unsubscribe.
48     *
49     * @type { number }
50     * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
51     * @systemapi hide for inner use
52     * @since 8
53     */
54    finalKey: number;
55
56    /**
57     * The final key press down or up.
58     *
59     * @type { boolean }
60     * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
61     * @systemapi hide for inner use
62     * @since 8
63     */
64    isFinalKeyDown: boolean;
65
66    /**
67     * Duration of final key press.
68     *
69     * @type { number }
70     * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
71     * @systemapi hide for inner use
72     * @since 8
73     */
74    finalKeyDownDuration: number;
75  }
76
77  /**
78   * Subscribe system keys.
79   *
80   * @param { 'key' } type - type of the inputevent about input which is to be subscribed.
81   * @param { KeyOptions } keyOptions - the key events about input which is to be subscribed.
82   * @param { Callback<KeyOptions> } callback - callback function, receive reported data.
83   * @throws { BusinessError } 401 - Parameter error.
84   * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
85   * @systemapi hide for inner use
86   * @since 8
87   */
88  function on(type: 'key', keyOptions: KeyOptions, callback: Callback<KeyOptions>): void;
89
90  /**
91   * Subscribe system keys.
92   *
93   * @param { 'key' } type - type of the inputevent about input which is to be subscribed.
94   * @param { KeyOptions } keyOptions - the key events about input which is to be subscribed.
95   * @param { Callback<KeyOptions> } callback - callback function, receive reported data.
96   * @throws { BusinessError } 401 - Parameter error.
97   * @syscap SystemCapability.MultimodalInput.Input.InputConsumer
98   * @systemapi hide for inner use
99   * @since 8
100   */
101  function off(type: 'key', keyOptions: KeyOptions, callback?: Callback<KeyOptions>): void;
102}
103
104export default inputConsumer;