Key Detection Demo
Demo overview
This demo detects key events by listening to the state of the user UBOOT key. After obtaining a key event, the demo matches the key value and then handles the event. To test other keys, modify the corresponding device node and source code.
The UBOOT key used in this demo is the one in the red box below.

Procedure
Open a terminal and use the evtest command to find the event device node corresponding to the UBOOT key — the UBOOT key corresponds to "adc-keys". This command can be run from any path.
evtest
From the query result, the event device node corresponding to the UBOOT key is event2.
Copy the executable smdt_key_demo from this demo's bin directory (05-Development Materials\Software Development Materials\linux_demo\smdt_key_demo\bin) to the board's filesystem (the source code is available under the src path).
In the terminal, run the following command to switch to the directory containing the smdt_key_demo executable.
cd ‘文件所在目录’After switching, run ls to confirm that smdt_key_demo is in the current directory.
lsIf the executable smdt_key_demo is present in the current directory, continue. Run the following command to change the file's permissions.
chmod 777 smdt_key_demoAfter changing the permissions, run the following command to verify the change.
ls -ld smdt_key_demoThe result should be: -rwxrwxrwx 1 root root 13824 Mar 4 01:22 smdt_key_demo
-rwxrwxrwx indicates the permission change succeeded and the file is executable; you may continue.
Run the command to view the program's parameter information. Note that event2 in the following command must be adjusted according to the result returned by the earlier evtest command.
./smdt_key_demo -help
./smdt_key_demo -d /dev/input/event2Now press the board's UBOOT key; the program will detect the key event and print the key status.
The test result is shown below:
Press "Ctrl+C" to exit the test.
